Pattern: Standard Install
Show-InstallationWelcome -CloseApps 'outlook,teams' -AllowDefer -DeferTimes 2
Show-InstallationProgress
Execute-MSI -Action Install -Path 'Files\app.msi' -Parameters 'ALLUSERS=1 REBOOT=ReallySuppress'
Exit-Script -ExitCode $mainExitCode
Pattern: Standard Uninstall
$app = Get-InstalledApplication -Name 'Contoso App'
if ($app) {
Execute-MSI -Action Uninstall -Path $app.ProductCode -Parameters '/qn /norestart'
}
Exit-Script -ExitCode 0
Pattern: Repair + Logging Standard
Write-Log -Message 'Starting repair phase.' -Severity 1
Execute-MSI -Action Repair -Path '{11111111-2222-3333-4444-555555555555}' -Parameters '/qn /L*v C:\Windows\Logs\Software\Contoso-repair.log'
Exit-Script -ExitCode $mainExitCode
Pattern: Preflight Checks
$freeGb = [math]::Round((Get-PSDrive C).Free / 1GB, 2)
if ($freeGb -lt 2) {
Show-InstallationPrompt -Message 'Nicht genug Speicherplatz.' -Icon Stop
Exit-Script -ExitCode 60001
}
Execute-Process -Path 'prereq.exe' -Parameters '/quiet /norestart'