diff --git a/Microsoft.PowerShell_profile.ps1 b/Microsoft.PowerShell_profile.ps1 index 4c0de8c..19846ef 100644 --- a/Microsoft.PowerShell_profile.ps1 +++ b/Microsoft.PowerShell_profile.ps1 @@ -231,7 +231,8 @@ function uptime { # reformat lastBoot $lastBoot = $bootTime.ToString("$dateFormat $timeFormat") } else { - $lastBoot = net statistics workstation | Select-String "since" | ForEach-Object { $_.ToString().Replace('Statistics since ', '') } + # the Get-Uptime cmdlet was introduced in PowerShell 6.0 + $lastBoot = (Get-Uptime -Since).ToString("$dateFormat $timeFormat") $bootTime = [System.DateTime]::ParseExact($lastBoot, "$dateFormat $timeFormat", [System.Globalization.CultureInfo]::InvariantCulture) }