handle errors accessing registry in Uninstall-MSI
This commit is contained in:
@@ -806,8 +806,11 @@ Function Get-GUIDFromMSIUninstallString ([string]$str) {
|
||||
Function Uninstall-MSI ([Parameter(ValueFromPipeline=$true)][string[]]$APP_NAMES) {
|
||||
PROCESS {
|
||||
# Get all of the uninstall registry keys
|
||||
$UNINSTALL_KEYS = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
|
||||
$UNINSTALL_KEYS += Get-ChildItem -Path HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall
|
||||
$UNINSTALL_KEYS = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall -ErrorAction SilentlyContinue
|
||||
$UNINSTALL_KEYS += Get-ChildItem -Path HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall -ErrorAction SilentlyContinue
|
||||
|
||||
# Exit if we can't find any software at all
|
||||
If ( $UNINSTALL_KEYS.Length -eq 0 ) { LogErr "Attempted to uninstall ${APP_NAMES} but could not find any installed apps in the Windows Registry" ; Return }
|
||||
|
||||
# Array to store custom objects about each installed MSI app
|
||||
$INSTALLED_APPS = @()
|
||||
|
||||
Reference in New Issue
Block a user