Script for getting last reboot timestamp (2008r2)
Solution 1:
Nixphoe's answer is definitely correct, but I want to add on how to get lastbootuptime for the multiple computers (the output can also be redirected to a file if needed):
Get Last Boot Time for Multiple Machines
$compname = Get-Content -Path C:\computers.txt
foreach ($comp in $compname) {
Get-WmiObject win32_operatingsystem -ComputerName $comp| select CSName, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}
}
C:\computers.txt
- put computer hostnames one in a row here
Solution 2:
For me, systeminfo is really slow. If you have powershell 3, you should be able to use something like
Get-CimInstance -ComputerName $yourcomputerObj -ClassName win32_operatingsystem | select csname, lastbootuptime
or
Get-WmiObject win32_operatingsystem -ComputerName $yourcomputerObj | select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}
Link