I use the below script in a powershell module. Use it with invoke-command to run against multiple computers. The problem is when I run from PS v5, it gives a different result as compared to running from PS v3. ( different result means : in PSv3, it gives local time for reboot Time, rather then returning me that Remote computer's Time; while if I run from a machine with PS v5, it gives the
Can someone please explain why
function get-bootTime{
$ht=@{}
$server = $env:Computername
$rawBootTime = get-winevent -FilterHashtable @{logname='system';<wbr />providername='eventlog';id=<wbr />6005} | ? {$_.message -eq "The Event log service was started."} |sort timecreated -desc | select -First 1
Rather than convert uptime to a string, a TimeSpan is much more useful and it will return in a readable format by default, but if I only care about the hours I don’t have to parse it out.