このエントリーをはてなブックマークに追加


PowerShellでuptimeファンクションを作ってみる

LinuxなどUNIXコマンドのuptimeコマンドをPowerShellでuptimeファンクションを作ってみました。
以下にサンプルスクリプトを記します。


関連記事

uptimeファンクション

サンプルスクリプト

uptimeのサンプルスクリプトになります。

Function uptime() {
  [DateTime]::Now -  [Management.ManagementDateTimeConverter]::ToDateTime((Get-WmiObject Win32_OperatingSystem).LastBootUpTime) |
  Select-Object Days, Hours, Seconds, Milliseconds| Format-Table -AutoSize
}

実行結果

PowerShell上で起動したときのスクリーンショットです。

01.png
 

以上、PowerShellでuptimeファンクションを作ってみたでした。



添付ファイル: file01.png 474件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-01-16 (土) 22:58:10