-
-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into defender-toggle
- Loading branch information
Showing
6 changed files
with
70 additions
and
279 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
49 changes: 49 additions & 0 deletions
49
...utables/AtlasModules/Scripts/Modules/Uninstall-MsiexecByName/Uninstall-MsiexecByName.psm1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<# | ||
.Synopsis | ||
Uninstalls MSIExec uninstaller applications by name. | ||
.Description | ||
Uninstalls applications that use MSIExec uninstallers recursively based on a | ||
wildcarded display name (DisplayName in Registry). | ||
.Parameter Name | ||
The display name of the MSIExec uninstaller application(s) to wildcard | ||
and uninstall. | ||
.Example | ||
# Uninstalls any apps matching "Microsoft Update Health Tools" | ||
Uninstall-MsiexecAppByName -Name "Microsoft Update Health Tools" | ||
#> | ||
|
||
function Uninstall-MsiexecAppByName { | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$Name | ||
) | ||
|
||
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) { | ||
throw "Uninstall-MsiexecAppByName: Not running as an administrator!" | ||
} | ||
|
||
$uninstallKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | ||
$uninstallKeys = Get-ChildItem -Path $uninstallKeyPath -EA SilentlyContinue | ||
|
||
foreach ($key in $uninstallKeys.PSPath) { | ||
$displayName = (Get-ItemProperty -Path "$key").DisplayName | ||
if ($displayName -like "*$Name*") { | ||
$uninstallString = (Get-ItemProperty -Path "$key").UninstallString | ||
if ($uninstallString -like "*MsiExec.exe*") { | ||
$foundKey = $key | Split-Path -Leaf | ||
Write-Warning "Uninstalling $displayName..." | ||
Start-Process -FilePath "msiexec.exe" -ArgumentList "/qn /X$foundKey REBOOT=ReallySuppress /norestart" | ||
} | ||
} | ||
} | ||
|
||
if ($null -eq $foundKey) { | ||
throw "Uninstall-MsiexecAppByName: No app found with an MSIExec uninstaller with the display name containing '$Name'." | ||
} | ||
} | ||
|
||
Export-ModuleMember -Function Uninstall-MsiexecAppByName |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.