uptime.ps1
$lastBootUp = Get-WmiObject -Class Win32_OperatingSystem | Select-Object LastBootUpTime
$lastBootUpTime = [Management.ManagementDateTimeConverter]::ToDateTime($lastBootUp.LastBootUpTime)
$uptime = (Get-Date) - $lastBootUpTime
"System has been running for: " + $uptime.TotalDays + " days, " + $uptime.Hours + " hours, " + $uptime.Minutes + " minutes."
运行效果
PS C:\Users\yeqiang> & C:\powershell\uptime.ps1
System has been running for: 0.00554322553240741 days, 0 hours, 7 minutes.
吐槽下,powershell下没有类似vim的字符界面文本编辑器,非常不方便!
1402

被折叠的 条评论
为什么被折叠?



