Get Last Windows boot up time with Powershell

22 July,2016 by Jack Vamvas

Question: How can I get the last Windows boot up time with Powershell? I need to be able to gather this information as part of post – patching process.

Answer: The Get_WmiObject cmdlet   will allow you to return the last boot up time for Windows.   

This is a sample code  that will return the LastBootUpTime on a specific server.

 

Get-WmiObject win32_operatingsystem | select csname, @{LABEL=’LastBootUpTime’
;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}

You can extend this code to run on multiple servers. This may be in the situation of multiple reboots have occurred, and you want to iterate through the servers. There are a few ways of completing . Read through this post as an example and customise to your requirements Powershell - run script on all sql servers

 


Author: Jack Vamvas (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Get Last Windows boot up time with Powershell


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer