Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Pick the last object on a list

$
0
0

I query each domain controller to get the last log time for a user on that DC. I do this because I need the exact times.  I get four times, $DC01 to $DC04, returned which I can sort like so

$LastDate="$dc01","$dc02","$dc03","$dc04"

PS U:\> $LastDate

03/01/2015 09:12:24

02/28/2015 10:12:50

03/01/2015 09:12:24

03/01/2015 09:13:10

PS U:\> $LastDate = $lastDate | Sort-Object

PS U:\> $LastDate

02/28/2015 10:12:50

03/01/2015 09:12:24

03/01/2015 09:12:24

03/01/2015 09:13:10

So how would I know create a variable like $LastRecord from the last record in $LastDate

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles