powershell-profile
powershell-profile copied to clipboard
Suggestion Uptime change
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