PowershellでWindowsバージョン情報の取得方法

PowerShell

systeminfoコマンドを使って取得

> systeminfo
ホスト名:               YKKKKKKSD
OS 名:                  Microsoft Windows 10 Pro
OS バージョン:          10.0.19045 N/A ビルド 19045
OS 製造元:              Microsoft Corporation
OS 構成:                メンバー ワークステーション
OS ビルドの種類:        Multiprocessor Free
・・・

Get-ComputerInfo Cmdletを利用

> Get-ComputerInfo
WindowsBuildLabEx                                       : 19041.1.amd64fre.vb_release.191206-1406
WindowsCurrentVersion                                   : 6.3
WindowsEditionId                                        : Professional
WindowsInstallationType                                 : Client
WindowsInstallDateFromRegistry                          : 2021/09/03 5:33:26
WindowsProductId                                        : 00330-52440-68871-AAOEM
WindowsProductName                                      : Windows 10 Pro
WindowsRegisteredOrganization                           :
・・・

パイプラインを利用して Select-Object Cmdletにて個別の情報のみを取得することができます。

> Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion

WindowsProductName WindowsVersion
------------------ --------------
Windows 10 Pro     2009

System.Environmentを領して取得

> [System.Environment]::OSVersion.Version

Major  Minor  Build      Revision
-----    -----     ---------  --------
10      0         22000   0

レジストリからバージョンを取得

Windows バージョン情報の確認・取得方法 – 情シス・社内SE

WMIからバージョンを取得

> (Get-CimInstance Win32_OperatingSystem).version
10.0.22000

コメント