ChrisTitusTech / powershell-profile

Pretty PowerShell that looks good and functions almost as good as Linux terminal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion Uptime change

BourbonCrow opened this issue · comments

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