I'm looking for a powershell script that will call uptime.exe and compare the output to the date/time stamp on the boostat.dat file in c:\Windows directory.  This is needed to run remotely on several servers and can be then activated through a 3rd party tool for operational management of Windows 2003/2008/& 2012 servers.

1 Comment   [ + ] Show Comment


  • # Requires PowerShell 3.0
    $lastbootuptime = Get-CimInstance -ClassName win32_operatingsystem | select lastbootuptime

    [datetime]$currenttime = get-date -Format "yyyy-MM-dd HH:mm:ss"

    $runningtime = $currenttime - $lastbootuptime.lastbootuptime
Please log in to comment

There are no answers at this time


Answer this question or Comment on this question for clarity