寫了個powershell列出上次開機時間,已開機時間,開機次數
$boottime=(Get-CimInstance Win32_OperatingSystem).LastBootUpTime;
$uptime = (Get-Date) - $boottime;
$bootid=Get-ItemPropertyValue -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters' -Name 'BootId';
Write-Host "`n========= System Boot Information ===============" -ForegroundColor Green
Write-Host ('Last Boot : '+$boottime)
Write-Host ('Uptime : {0} Days, {1:D2}:{2:D2}:{3:D2}' -f $uptime.Days, $uptime.Hours, $uptime.Minutes, $uptime.Seconds)
Write-Host 'Boot Time : ' -NoNewline
Write-Host ('{0}' -f $bootid)
Write-Host "=================================================" -ForegroundColor Gree
儲存成 BootTime.ps1
再用以下指令就可以執行
powershell -ExecutionPolicy Bypass -File BootTime.ps1