Using Powershell to get your server’s uptime!

I have always missed the option in windows to just easily see the uptime from a server.

Ofcourse we have the uptime.exe available from Microsoft, but I wanted to have something available directly from powershell.

For starters we could get the last bootuptime from WMI with the following query

Since this is not really in a nice format, lets change it into something we can read

Now that we have the bootup time/date in a readable format we can substract this date from our current time/date to get our actual uptime.

And there you go, you can now see the uptime for your server. I took this along a bit and created a powershell function to make it more usable for everyone in the company.

Now you only need to type Get-Uptime “servername” to get the uptime for the server you wish 🙂


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.