Skip to content

Instantly share code, notes, and snippets.

@mark05e
Created April 6, 2021 20:52
Show Gist options
  • Save mark05e/bfc136f2c304ae0e2b9e3e33d2fedf0a to your computer and use it in GitHub Desktop.
Save mark05e/bfc136f2c304ae0e2b9e3e33d2fedf0a to your computer and use it in GitHub Desktop.
Check .Net framework on the filesystem and registry
# Check installed .Net versions
# ref: https://gist.github.com/MyITGuy/b4497f042d59f1c7b91d
# Using filesystem
Write-Host "Checking Filesystem ..."
$x= Get-ChildItem -Path "$($env:WINDIR)\Microsoft.NET\Framework*" |
ForEach-Object { Get-ChildItem -Path "$($_.PSPath)" |
Where-Object {$_.Name.StartsWith('v') -and $_.PSIsContainer -eq $true -and ((Test-Path -Path "$($_.FullName)\mscorlib.dll" -PathType Leaf) -eq $true)}
} | Select-Object @{Name="Version";Expression={$_.Name.TrimStart('v')}},@{Name="Bitness";Expression={if (!$_.Parent.ToString().TrimStart('Framework')) {[int]32} else {[int]$_.Parent.ToString().TrimStart('Framework')}}} |
Sort-Object -Property Version;
$x | Format-Table -AutoSize;
# Using Registry
Write-Host "Checking Registry ..."
$y= Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse |
Get-ItemProperty -Name Version, Release -ErrorAction SilentlyContinue |
Where-Object { $_.PSChildName -match '^(?!S)\p{L}' } |
Select-Object -Property Version, Release |
Sort-Object -Property Version;
$y | Format-Table -AutoSize;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment