Last active
May 18, 2023 18:23
-
-
Save m4ss1m0g/3b2b0edd8d5eb73424cbf247265e0bb0 to your computer and use it in GitHub Desktop.
Lists all installed software, including any that is not visible with PowerShell
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
function Get-Installed { | |
[CmdletBinding()] | |
param ( | |
# The name of the software | |
[Parameter(Mandatory = $true)] | |
[string] $Name | |
) | |
begin { | |
$PATHS = @( | |
"HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall", | |
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | |
) | |
} | |
process { | |
$installed = $null | |
ForEach ($path in $PATHS) { | |
$installed += Get-ChildItem -Path $path | | |
ForEach-Object { Get-ItemProperty $_.PSPath } | | |
Where-Object { $null -ne $_.DisplayName -and $_.DisplayName.Contains($Name) } | | |
Select-Object DisplayName, DisplayVersion, PSChildName | | |
Sort-Object -Property DisplayName | |
} | |
$installed | |
} | |
end { | |
} | |
} | |
function Remove-Installed { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true)] | |
$Guid | |
) | |
process { | |
Write-Verbose "Removing $Guid" | |
$a = "/x " + $Guid | |
Start-Process msiexec -Wait -ArgumentList $a | |
} | |
} | |
# Examples | |
# | |
# Get ALL software containing (case-SENSITIVE) .NET | |
# Get-Installed -Name .NET | |
# | |
# Get ALL software containing (case-SENSITIVE) .NET AND 3.1.10 | |
# Get-Installed -Name .NET | Where-Object {$_.DisplayName.Contains("3.1.10")} | |
# | |
# Get ALL software containing (case-SENSITIVE) .NET AND 3.1.10 AND Remove that software | |
# Get-Installed -Name .NET | Where-Object {$_.DisplayName.Contains("3.1.10")} | Select -Expand PsChildName | Remove-Installed | |
# | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment