LinuxなどUNIXコマンドのuptimeコマンドをPowerShellでuptimeファンクションを作ってみました。
以下にサンプルスクリプトを記します。
uptimeのサンプルスクリプトになります。
Function uptime() {
[DateTime]::Now - [Management.ManagementDateTimeConverter]::ToDateTime((Get-WmiObject Win32_OperatingSystem).LastBootUpTime) |
Select-Object Days, Hours, Seconds, Milliseconds| Format-Table -AutoSize
}
PowerShell上で起動したときのスクリーンショットです。
以上、PowerShellでuptimeファンクションを作ってみたでした。