LoginSignup
0
0

More than 3 years have passed since last update.

PowerShellでOSのバージョンを取得

Last updated at Posted at 2021-04-01

以下のコマンドを実行すると、OSの関連の情報が取得できます。

# OSの情報を取得
Get-WmiObject Win32_OperatingSystem

一覧の中から特定の値を取得したい場合、たとえばVersionだけを取得したい場合はこう。

# OSのバージョンを取得
(Get-WmiObject Win32_OperatingSystem).Version

Windows10か否かで条件を分岐するなんてときに便利です。

# windows10以下なら
if((Get-WmiObject Win32_OperatingSystem).Version -lt 10){
    #警告を出して中断、とかね。
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0