Skip to content

Instantly share code, notes, and snippets.

@gabriel-vanca
Last active August 2, 2024 01:09
Show Gist options
  • Save gabriel-vanca/85d811da417722b33e469d925737d772 to your computer and use it in GitHub Desktop.
Save gabriel-vanca/85d811da417722b33e469d925737d772 to your computer and use it in GitHub Desktop.
Manage DotNet
function Get-InstalledDotNet {
<#
.SYNOPSIS
Display version of .net installed on a system
.DESCRIPTION
Query the registry on a local or remote system to display the version of .net installed
.PARAMETER ComputerName
The name of the computer to run the query on
#>
PARAM([String]$ComputerName = $ENV:COMPUTERNAME)
IF ($ComputerName -ne $ENV:COMPUTERNAME) {
[array]$netTypes = Invoke-CommandName { Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\" -Recurse | Get-Item | Get-ItemProperty }
}
else {
$netTypes = Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\" -Recurse | Get-Item | Get-ItemProperty
}
Foreach ($item in $netTypes) {
IF ($item.InstallPath) {
$Type = $item.PSChildName
$Version = $item.Version
$Release = $item.Release
$InstallPath = $item.InstallPath
$DotNet = New-Object -TypeName psobject
$DotNet | Add-Member -MemberType NoteProperty -Name Type -Value $Type
$DotNet | Add-Member -MemberType NoteProperty -Name Version -Value $Version
$DotNet | Add-Member -MemberType NoteProperty -Name Release -Value $Release
$DotNet | Add-Member -MemberType NoteProperty -Name InstallPath -Value $InstallPath
$DotNet
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment