Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Windows Last Reboot Timestamp?

Tags:

powershell

I have a PC on remote connected by network, but it occasionally crashes or is restarted by remote users. After the restart, some services and applications have to be in running status. So I would like to find out the reboot as soon as possible. I think PS may be a good choice with some scripts so that I could make remote call to get the last reboot timestamp information.

Is there any way to get a remote Windows XP last reboot timestamp by using PowerShell 2.0(its remoting feature)?

like image 779
David.Chu.ca Avatar asked Mar 19 '10 04:03

David.Chu.ca


People also ask

How can I tell the last time a server was rebooted?

Login to Windows Server. Launch the Event Viewer (type eventvwr in run). In the event viewer console expand Windows Logs. Click System and in the right pane click Filter Current Log.

How can I tell who rebooted a Windows Server?

Double click the recent event. In the event properties box, you can see the person who initiated the restart of server. Click Close.


2 Answers

You can do this via WMI:

$wmi = Get-WmiObject -Class Win32_OperatingSystem -Computer "RemoteMachine"
$wmi.ConvertToDateTime($wmi.LastBootUpTime)
like image 105
Justin R. Avatar answered Oct 26 '22 21:10

Justin R.


For a remote computer:

$wmi = Get-WmiObject -Class Win32_OperatingSystem -Computer RemoteComputerName
$wmi.ConvertToDateTime($wmi.LastBootUpTime)
like image 45
aphoria Avatar answered Oct 26 '22 21:10

aphoria