PowerShell Script to run uptime.exe and compare with date listed on bootstat.dat

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 - martin99 7 years ago

Answers (0)

Be the first to answer this question

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ