Getting boot time of the machine could come in handy on most of the situation.
I normally get this request from teams saying “Hey can you get me the boot time of the machine” – i go like you know what use the script below.
$computername=$env:computername
$os=Get-WmiObject win32_operatingsystem -computername $computername
Write-Host ("Last boot: {0}" -f $os.ConvertToDateTime($os.lastbootuptime))
Write-Host ("Uptime : {0}" -f ((get-date) - $os.ConvertToDateTime($os.lastbootuptime)).tostring())
They go like you are a Star 😉
