log msg if no product was uninstalled

This commit is contained in:
2023-01-18 19:13:41 -05:00
parent 0fa22b397c
commit 933105f0bf
+5 -1
View File
@@ -24,6 +24,9 @@ Foreach ( $reg in $UNINSTALL_KEYS ) {
# Get the ModifyPath
$MODIFYPATH = $REG_PROPERTY.ModifyPath
# Track whether an app was uninstalled or not
$PRODUCTUNINSTALLED = 0
# Make sure the DisplayName matches what we're looking for
If ( $DISPLAY_NAME -ilike $APP_NAME ) {
# Make sure the software was installed using an MSI
@@ -38,7 +41,7 @@ Foreach ( $reg in $UNINSTALL_KEYS ) {
If ( $PRODUCT_CODE ) {
LogMsg "Uninstalling ${DISPLAY_NAME} ${PRODUCT_CODE}"
$arguments = '/X{' + $PRODUCT_CODE + '} /qn /norestart'
Try { Start-Process -FilePath "msiexec.exe" -ArgumentList $arguments -Wait }
Try { Start-Process -FilePath "msiexec.exe" -ArgumentList $arguments -Wait ; $PRODUCTUNINSTALLED++ }
Catch { LogErr $_.Exception.Message }
}
}
@@ -46,4 +49,5 @@ Foreach ( $reg in $UNINSTALL_KEYS ) {
LogMsg "Cannot uninstall ""${DISPLAY_NAME}""`n UninstallString: ${UNINSTALLSTRING}"
}
}
If ( $PRODUCTUNINSTALLED -gt 0 ) { LogMsg "No product matching ${APP_NAME} was found"}
}