banshee is under active development: collectors will keep changing, and a version you publish will likely need adjustments. For stable use, wait for version 1.0.0.

Windows

banshee/windows-collection/windows/winrm/

uptime

The time since a Windows started, and its recent restart, by WinRM and PowerShell

  • windows
  • winrm
  • powershell
  • uptime

by banshee1 installation2 versions

v2Latest

Published on October 28, 2026. One naming convention across collections; documentation completed.

Keen 1.0.0 · 25 lines
// The time since a Windows started, by WinRM. A restart shows as a time since boot shorter than the
// threshold of "Recent reboot".
// Runs one PowerShell script that only reads the raw counter SystemUpTime of
// Win32_PerfRawData_PerfOS_System: the instant the system started, against the instant of the reading,
// Timestamp_Object, both in ticks of Frequency_Object. All three are integers: no date, no time zone and no
// change of summer time to read.
// The script is the one of windows/ssh/uptime, without the powershell -Command "..." that cmd.exe needs
// there.
need('protocol:winrm');

output('uptime', 'number', array('label' => 'Time since boot', 'unit' => 'h'));

watch.below('rebooted', 'Recent reboot', 'uptime', array('warning' => 0.5));

$read = winrm.run("Get-CimInstance Win32_PerfRawData_PerfOS_System"
    . " | Select-Object SystemUpTime, Timestamp_Object, Frequency_Object | ConvertTo-Json -Compress");
$answer = text.trim($read['output']);
if (list.count(text.match($answer, '^\{')) == 0) {
    fail('misconfigured', 'PowerShell did not return Win32_PerfRawData_PerfOS_System', $answer . $read['errors']);
}
$system = json.read($answer);
if ($system['Frequency_Object'] <= 0 || $system['Timestamp_Object'] < $system['SystemUpTime']) {
    fail('misconfigured', 'Win32_PerfRawData_PerfOS_System gives no time since start', $answer);
}
value('uptime', number.round(($system['Timestamp_Object'] - $system['SystemUpTime']) / $system['Frequency_Object'] / 3600, 2));