ChrisTitusTech / powershell-profile

Pretty PowerShell that looks good and functions almost as good as Linux terminal
551 stars 320 forks source link

Suggestion Uptime change #36

Open BourbonCrow opened 8 months ago

BourbonCrow commented 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
}

image preview of how that looks in powershell, works in both 5 and 7