See the number of days an endpoint is up
This agent procedure was created because several Kaseya VSA users mentioned to me that they rather see the number of days an endpoint is up rather than seeing when the last reboot happened. This is a simple agent procedure that gets the System Uptime in days using a single PowerShell command then documents the result in the Agent Logs and in a Custom Field so you can see its status and even report on it.
It is important to understand that this will show the number of days since the last time the endpoint was booted up. This is useful for servers since they are normally always on. However, keep in mind that if you are doing this for workstations, it will not start counting after a machine woke up from hibernation, woke from sleep, or a laptop that the lid was closed then opened again… It will always show the number of days since the operating system was booted up.
Windows System Uptime has no reviews.
I need a procedure script to reboot an endpoint based of uptime. For example if uptime is greater then x days, request a reboot or idle check then reboot.
Hey Jack, I build a procedure that can do this. For us checks If the system uptime is greater than 5, if so it asks the users to reboot or postpone. They have the ability to postpone for 2 hours as long as they want, however, the more they postpone the more annoyed they get because of the message.
Do not see an option to upload the XML so feel free to email me at firstname.lastname@example.org
I am seeing this only working on Windows 10. Windows 7 shows as unsupported OS. Am I missing something?
Yeah, Cim-Instance won't work on Win7 for this. Win7 has PowerShell 2.0 natively. So you'd have to install the WMF to get later versions of PowerShell on the computer (more here: https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/wmf/setup/install-configure?view=powershell-7.1#installing-wmf-51-on-windows-server-2008-r2-and-windows-7). Probably not worth it.
But you can use wmi to get the days on either Win7 and Win10:
((Get-Date) - ([System.Management.ManagementDateTimeconverter]::ToDateTime((Get-WmiObject Win32_OperatingSystem -Namespace root/CIMV2).LastBootUpTime))).Days
Isn't get-date and Get-wmiObject powershell commands?
I tried pasting your last line into wmic from the command prompt and it failed. But pasting it into a Windows 10 powershell prompt worked.