PowerShell Module to wrap the WindowInstaller Objects, Methods, and Properties
https://learn.microsoft.com/en-us/windows/win32/msi/windows-installer-reference
Available via PowerShell Gallery, or download/clone this repository.
Install-Module -Name PS-WindowsInstaller
# -- OR --
Import-Module "C:\Path\To\Downloaded_Cloned\Repository\PS-Installer.psd1"$PackageSession = Open-WindowsInstallerPackage -PackagePath 'C:\MyInstaller.msi'
$Return = Invoke-WindowsInstallerSessionAction -Session $PackageSession -Action 'INSTALL'$Installer = New-WindowsInstallerInstaller
Set-WindowsInstallerInstallerLog -LogMode 'v+' -LogFile 'C:\Temp\My.Log' -Installer $Installer
Set-WindowsInstallerInstallerUILevel -UILevel 2 -Installer $Installer
$AllProducts = Get-WindowsInstallerInstallerProduct |% { Get-WindowsInstallerInstallerProductInfo $_ }
$BadProducts = $AllProducts |?{$_.ProductName -match 'BadProduct'}
$BadProducts.ProductCode |%{
Write-Host ('Uninstalling {0}' -f $_)
Set-WindowsInstallerInstallerProduct -ProductCode $_ -InstallState msiInstallStateAbsent -Installer $Installer
}