This function will take a server name or array of server names, and return Server Up Time in form of TimeSpan data type.
Why this is different ?
What makes this script different than other scripts is two things:
– Faster : Instead of getting all WMI data from Win_OperatingSystem name space, we will only get the server up time property, so less data transfer the wire
– Returns object with two properties : ComputerName, and UpTime.
– Better error handling : Even if there is trouble getting WMI data from the remote computer, the uptime property will be replaced with “n/a” instead of throwing exception.
– Returns TimeSpan : So the UpTime property will be TimeSpan, so you can browse its properties and get uptime in days, minutes, seconds, or even more accurate information.
– Flexible Input Data: Can take input from the pipeline in form of single server or array of server names.
Download the script
You can download the script from here Get-CorpUpTime