Sort by LastBootUpTime

Hello All,

I’m looking for a little help in sorting a list of servers by their last boot up time. For some reason I cannot get sort-object to work. Any help would be appreciated.

$servers = get-content -Path c:servers.txt foreach ($server in $servers) { if (Test-Connection -ComputerName $server -Count 1 -ErrorAction SilentlyContinue) { Get-WmiObject -Computername $Server win32_operatingsystem | select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}} | sort LastBootUpTime } else { Write-Host "$server, No Ping" } } 

submitted by /u/FEXSO
[link] [comments]

Leave a Reply