Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Last active November 25, 2017 03:19
Show Gist options
  • Save techthoughts2/7242cf86522ce67167353207ae83f8e7 to your computer and use it in GitHub Desktop.
Save techthoughts2/7242cf86522ce67167353207ae83f8e7 to your computer and use it in GitHub Desktop.
#create new PowerShell object to hold Windows Version Info
$WinVer = New-Object -TypeName PSObject
#retrieve version information from registry
$WinVer | Add-Member -MemberType NoteProperty -Name Major -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' CurrentMajorVersionNumber).CurrentMajorVersionNumber
$WinVer | Add-Member -MemberType NoteProperty -Name Minor -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' CurrentMinorVersionNumber).CurrentMinorVersionNumber
$WinVer | Add-Member -MemberType NoteProperty -Name Release -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' ReleaseId).ReleaseId
$WinVer | Add-Member -MemberType NoteProperty -Name Build -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' CurrentBuild).CurrentBuild
$WinVer | Add-Member -MemberType NoteProperty -Name Revision -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' UBR).UBR
#output information
$WinVer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment