Open BourbonCrow opened 8 months ago
function uptime { $bootuptime = (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime $CurrentDate = Get-Date $uptime = $CurrentDate - $bootuptime #Windows Powershell only net statistics workstation | Select-String "since" | foreach-object {$_.ToString().Replace('Statistics since ', 'Last Reboot: ')} Write-Output "Uptime: Days: $($uptime.days), Hours: $($uptime.Hours), Minutes:$($uptime.Minutes), Seconds:$($uptime.Seconds)" Remove-Variable bootuptime Remove-Variable CurrentDate Remove-Variable uptime }
preview of how that looks in powershell, works in both 5 and 7