Uptime of the server with PowerShell
Hi peoples.
This morning I had to check the Uptime of the server, and I must admit, I have totally forgot how to check the uptime of the server hehe…
Nevertheless, I have managed to find the command and check the uptime of the server.
This post is going to be really short, as there is only one tiny command which you have to run in order to check the uptime of the server.
I’m gonna show you how to do it in PowerShell 3.0, 2.0, and 1.0 (1.0 and 2.0 being the same).
Also check: ADDING A STATIC ROUTE
I am logged on my Windows Server 2012 right now at the moment, so lets check the version first by opening up PowerShell console and typing: $PSversionTable.psversion.major
As you may see, on Windows Server 2012, we are using Powershell version 3.
For PowerShell version 3, use the Get-CimInstance command, and select the LastBootUptime property from the Win32_OperatingSystem WMI class:
[php]Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime[/php]
For PowerShell version 1.0, and 2.0, we will use a little bit different command. We will use Get-WmiObject command, and then translate the returned date to a readable format:
[php]Get-WmiObject win32_operatingsystem | select csname, @{LABEL=’LastBootUpTime’ ;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}[/php]
Pingback: Adding a static route – Vlad's IT Blog – Troubleshooting, Tips, Tricks
Pingback: Creating a Roaming Profiles Share in Windows Server 2012 R2 – Vlad's IT Blog – Troubleshooting, Tips, Tricks