functions/softwareupdate/Get-InstalledDotNetComponents.ps1
function Get-InstalledDotNetComponents { [CmdletBinding()] param () $registryPaths = @( 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' ) $filterKeywords = @('Microsoft .NET', 'Microsoft ASP.NET', 'Framework', 'Runtime', 'SDK', 'HostFXR') $components = @() $apps = @() foreach ($path in $registryPaths) { $uninstallProperties = Get-ItemProperty -Path $path -ErrorAction SilentlyContinue foreach($filterKeyword in $filterKeywords) { $apps += $uninstallProperties | Where-Object { ($_.DisplayName -like "$filterKeyword*") -and ($_.Publisher -eq 'Microsoft Corporation') } } } foreach ($app in $apps) { $components += [PSCustomObject]@{ Name = $app.DisplayName Version = $app.DisplayVersion Publisher = $app.Publisher InstallDate = $app.InstallDate RegistryPath = $app.PSPath } } return $components | Sort-Object Name, Version } # function Get-InstalledDotNetComponents { # [CmdletBinding()] # param () # $registryPaths = @( # 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', # 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' # ) # $filter = 'Microsoft .NET','Microsoft ASP.NET','Framework','Runtime','SDK','HostFXR' # $components = foreach ($path in $registryPaths) { # Get-ItemProperty -Path $path -ErrorAction SilentlyContinue | # Where-Object { $_.DisplayName -and ($filter | Where-Object { $_ -and ($_.DisplayName -like "*$_*") }) -and $_.Publisher -eq 'Microsoft Corporation' } | # Select-Object @{n='Name';e={$_.DisplayName}}, # @{n='Installed';e={$_.DisplayVersion}}, # @{n='InstallLocation';e={$_.InstallLocation}}, # @{n='RegistryPath';e={$_.PSPath}} # } # return $components | Sort-Object Name, Installed # } |