視覚的に確認
-
Windowsキー + R
キーを押して、ファイル名を指定して実行のウィンドウを表示 -
winver
と入力してOK
PowerShell で 取得
20H2
よりも前か、 20H2 (以降)
か でやり方がちょっと異なります。
Windows 10 20H2 よりも前
$CurrentVersion = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
"Version " + $CurrentVersion.ReleaseId + " (OS Build " + $CurrentVersion.CurrentBuild + "." + $CurrentVersion.UBR + ")"
結果
Version 2009 (OS Build 19045.3803)
Windows 10 20H2 よりも前
$CurrentVersion = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
"Version " + $CurrentVersion.DisplayVersion + " (OS Build " + $CurrentVersion.CurrentBuild + "." + $CurrentVersion.UBR + ")"
またはワンライナーに(セミコロンで区切っているだけ)
$CurrentVersion = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"; "Version " + $CurrentVersion.DisplayVersion + " (OS Build " + $CurrentVersion.CurrentBuild + "." + $CurrentVersion.UBR + ")"
結果
Version 22H2 (OS Build 19045.3803)
両方まとめると
$CurrentVersion = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
if ($CurrentVersion.DisplayVersion -ne $null) { $DispVersion = $CurrentVersion.DisplayVersion } else { $DispVersion = $CurrentVersion.ReleaseId }
"Version " + $DispVersion + " (OS Build " + $CurrentVersion.CurrentBuild + "." + $CurrentVersion.UBR + ")"
結果
Version 22H2 (OS Build 19045.3803)