カテゴリー: IT
memo code3
投稿日時:
投稿者: yuruyuru
タグ: PowerShell, WindowsServer2019, インフラ
コメント数: コメントはありません

PowerShellのスクリプトで遊んでた時に作ったやつ。
PC又は、Serverの稼働時間をCドライブの何処かに出力するスクリプト。
echo +++++start+++++ >> C:\work\test\TotalBootTime.txt
#to day code
$date = Get-Date
Write-Output $date >> C:\work\test\TotalBootTime.txt
#Boot time code
$os = Get-WmiObject -Class Win32_OperatingSystem
$uptime = $os.ConvertToDateTime($os.LastBootUpTime)
Write-Output($date - $uptime) >> C:\work\test\TotalBootTime.txt
echo +++++end+++++ >> C:\work\test\TotalBootTime.txt