I have a list of ad-integrated computers and I need a list of them with their last reboot time. I found some comands like Get-WmiObject -ClassName win32_operatingsystem -ComputerName xxx | select csname, lastbootuptime
but it's not what I need. I would need a script because there are lots of computers.
I have no experience with PowerShell, if someone could help me with some suggestions.
PS C:\Users\XxX> Get-wmiobject win32_operatingsystem -ComputerName LC006909 | select csname, @{label='LastRestart';expression={$_.ConverToDateTime($_.LastBootUpTime)}}
csname LastRestart
------ -----------
LC006909
I get this output ... empty under LastRestart.
For me, systeminfo is really slow. If you have powershell 3, you should be able to use something like
or
Link
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
C:\computers.txt
- put computer hostnames one in a row hereThere are many ways to get the last boot time:
would do the trick, for example (in human readable format). Be aware of different languages here, in germany for example you would have to grep for "Systemstartzeit".
You could also try (language independent) wmi:
which will give you the Boot time in reversed format (like 20150915100340.494919+120)
I always use
which outputs
System Boot Time: 16/09/2015, 08:41:28 Time Zone: (UTC) Dublin, Edinburgh, Lisbon, London