Display last boot time with Powershell


To remotely find out the last boot time from multiple machines at the same time use the following script:

1..8 | % {$i=”{0:0}” -f $_;$server=”server$i”; invoke-command -computername $server -scriptblock { Get-WmiObject win32_operatingsystem | select csname,@{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}}}
Note that the script uses the server$i pattern to find out the last boot time of 8 servers at the same time.
Alternatively you can use one of the following commands on a single server:
(Get-CimInstance Win32_operatingSystem).lastbootuptime
Powershell last boot time

systeminfo | grep “System”

Powershell systeminfo command
 

net statistics server

Powershell net statistics server command
 

wmic os get LastBootUpTime

Last Boot Up Time Powershell
 

(Get-Date) – ([timespan]::FromMilliseconds([Math]::Abs([Environment]::TickCount)))

Get last boot up time with Powershell

Note that you can use the above command in an invoke-command statement to remotely find out the last boot time, just like in the following example:
invoke-command cmdlet
There are a lot of other methods in which you can achieve similar results, please feel free to post a comment with other commands that can be used.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s