Skip to content

Instantly share code, notes, and snippets.

@JimWolff
Created June 19, 2017 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JimWolff/b3d370d1ad43fe6343d9b83ff641d7d9 to your computer and use it in GitHub Desktop.
Save JimWolff/b3d370d1ad43fe6343d9b83ff641d7d9 to your computer and use it in GitHub Desktop.
Powershell to check which .Net version is installed
# credit: https://stackoverflow.com/a/3495491/665879
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse |
Get-ItemProperty -name Version,Release -EA 0 |
Where { $_.PSChildName -match '^(?!S)\p{L}'} |
Select PSChildName, Version, Release, @{
name="Product"
expression={
switch -regex ($_.Release) {
"378389" { [Version]"4.5" }
"378675|378758" { [Version]"4.5.1" }
"379893" { [Version]"4.5.2" }
"393295|393297" { [Version]"4.6" }
"394254|394271" { [Version]"4.6.1" }
"394802|394806" { [Version]"4.6.2" }
"460798" { [Version]"4.7" }
{$_ -gt 460798} { [Version]"Undocumented 4.7 or higher, please update script" }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment