memo code3

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

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny

PAGE TOP