Hi everyone,
I regularly use Remove-MSIAapplications in PSADT 3.8.4. I've built a suitable equivalent. I'm getting the message that the installation package cannot be opened. Nothing is being uninstalled, and I can still open it afterward. Does anyone have any ideas?
PSAppDeployToolkit.Extensions.psm1
function Uninstall-MSIByDisplayName {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]$DisplayName,
[switch]$ExactMatch,
[string]$AdditionalArguments = "/qn /norestart"
)
Write-ADTLogEntry -Message "Suche installierte MSI-Anwendung mit DisplayName: $DisplayName" -Severity 1
try {
if ($ExactMatch) {
$Applications = Get-ADTApplication | Where-Object {
$_.DisplayName -eq $DisplayName -and $_.WindowsInstaller -eq $true
}
}
else {
$Applications = Get-ADTApplication | Where-Object {
$_.DisplayName -like "*$DisplayName*" -and $_.WindowsInstaller -eq $true
}
}
if (!$Applications) {
Write-ADTLogEntry -Message "Keine passende MSI-Installation gefunden für: $DisplayName" -Severity 2
return
}
foreach ($App in $Applications) {
Write-ADTLogEntry -Message "Gefundene MSI-Anwendung: $($App.DisplayName) - ProductCode: $($App.ProductCode)" -Severity 1
if ($App.ProductCode) {
Start-ADTProcess -FilePath "msiexec.exe" `
-ArgumentList "/x $($App.ProductCode) $AdditionalArguments" `
-WindowStyle Hidden `
-WaitForMsiExec `
-ErrorAction SilentlyContinue
Write-ADTLogEntry -Message "Deinstallation gestartet für: $($App.DisplayName)" -Severity 1
}
else {
Write-ADTLogEntry -Message "Kein ProductCode gefunden für: $($App.DisplayName). Überspringe." -Severity 3
}
}
}
catch {
Write-ADTLogEntry -Message "Fehler bei der MSI-Deinstallation: $_" -Severity 3
throw
}
}
Invoke-AppDeployToolkit.ps1
![]()
cu
bolle
