22 July,2016 by Tom Collins
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
This is only a preview. Your comment has not yet been posted.
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.
Posted by: |