Retrieve System Uptime and Status

In this PowerShell script, we will check the system uptime and status of your machine, providing crucial information for system administrators and users alike. By utilizing this script, you can easily monitor your system’s performance and identify any potential issues before they escalate.
Furthermore, take advantage of ServerEngine to automate this process within your infrastructure. ServerEngine offers seamless integration and automation capabilities that can enhance your workflow and efficiency. With features like remote PowerShell script execution and real-time monitoring, you can ensure that your systems are running optimally with minimal effort. Check out how ServerEngine can transform your administrative tasks into streamlined processes.

$uptime = (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime
$uptimeDateTime = [Management.ManagementDateTimeConverter]::ToDateTime($uptime)
$uptimeSpan = New-TimeSpan -Start $uptimeDateTime -End (Get-Date)
Write-Output "System Uptime: $($uptimeSpan.Days) Days, $($uptimeSpan.Hours) Hours, $($uptimeSpan.Minutes) Minutes"
Write-Output "System Status: $(if ((Get-CimInstance -ClassName Win32_OperatingSystem).Status -eq 'OK') {'Operational'} else {'Non-Operational'})"