Created
March 22, 2017 13:29
-
-
Save istairbn/78552e41d0cc09903c0ed3c2b93c1762 to your computer and use it in GitHub Desktop.
PowerShell funciton to uninstall a list of programs by display name
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 Uninstall-Program{ | |
<# | |
.SYNOPSIS | |
Uninstalls Windows Programs using display name | |
.Parameter DisplayName | |
String match for the programs to uninstall. Accepts pipeline input | |
#> | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$True,ValueFromPipeline=$True)] | |
[String[]] | |
$DisplayName | |
) | |
$RegEntries = @() | |
ForEach($Name in $DisplayName){ | |
$RegEntries += Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.DisplayName -match $Name } | |
} | |
ForEach($Entry in $RegEntries){ | |
$Entry.DisplayName | |
$UninstallCommand = "/X `"$($Entry.PSChildName)`" /q" | |
Start-Process msiexec.exe -NoNewWindow -Wait -ArgumentList $UninstallCommand | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment