Created
May 4, 2018 13:21
-
-
Save Celoxocis/61d01bf4bbd5581ef399512904637b13 to your computer and use it in GitHub Desktop.
two scripts to quickly determine the installed dotnet-framework versions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://stackoverflow.com/questions/3487265/powershell-script-to-return-versions-of-net-framework-on-a-machine?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa | |
$Lookup = ConvertFrom-Csv 'Version|Release | |
4.5|378389 | |
4.5.1|378675 | |
4.5.1|378758 | |
4.5.2|379893 | |
4.6|393295 | |
4.6|393297 | |
4.6.1|394254 | |
4.6.1|394271 | |
4.6.2|394802 | |
4.6.2|394806 | |
4.7|460798 | |
4.7|460805 | |
4.7.1|461308 | |
4.7.1|461310 | |
' -Delimiter "|" | |
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 = { | |
$Lookup | ? Release -eq $_.Release | % Version | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the text from github | |
$url = "https://raw.githubusercontent.com/dotnet/docs/master/docs/framework/migration-guide/how-to-determine-which-versions-are-installed.md" | |
$md = Invoke-WebRequest $url -UseBasicParsing | |
# Replace the weird text in the tables, and the padding | |
# Then trim the | off the front and end of lines | |
$map = $md -split "`n" -replace " installed [^|]+" -replace "\s+\|" -replace "\|$" | | |
# Then select all the lines that start with ".NET Framework" | |
# and make sure we don't have duplicates | |
Select-String "^.NET" | Select -Unique | |
# Then remove the .NET Framework | |
$map = $map -replace ".NET Framework " -join "`n" | |
# And just output the script | |
@" | |
`$Lookup = ConvertFrom-Csv 'Version|Release | |
$map | |
' -Delimiter "|" | |
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={ | |
`$Lookup | ? Release -eq `$_.Release | % Version | |
} | |
} | |
"@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment