Powershell MSI Installer/Updater
Hi, if somebody needs a Powershell MSI Installer/Updater. Have fun.
Import-Module -Name 'Carbon.Windows.Installer'
$app = 'SwyxIt!'
$installerPath = '...\SwyxIt!German64.msi'
#1
$package = try {Get-Package -Name $app -ErrorAction Stop} catch {$false}
#2
$localVersion = if ($package -ne $false) {$package.Version}
#3
$isInstalled = if (-not($package -eq $false)) {$true} else {$false}
#4
$installerVersion = (Get-CMsi -Path $installerPath).ProductVersion
#5
$otherVersion = $localVersion -ne $installerVersion
$msi = 'msiexec.exe'
$msiArray = @(
"/i $installerPath"
"/qb+"
"ADDLOCAL="
@(
"PhoneClient"
"FaxClient"
"DesktopShortcut"
"DesktopShortcutFaxClient"
"StartupShortcut"
"OfficeUCSupport"
"Outlook2007Support"
"ClientMeeting"
"CLMgrTSP"
"Video"
"SwyxMeeting"
"FAnalytics"
"MsTeamsIntegration"
"MsTeamsIntegrationSettings"
)
)
$a1 = $msiArray[0..2]
$a2 = $msiArray[3..$msiArray.Length]
$msiArgs = "$a1" + "$a2".Replace(" ",",")
if ($isInstalled -and $otherVersion) {
Write-Host "update app"
Start-Process -FilePath $msi -ArgumentList $msiArgs -Wait
}
elseif ($isInstalled -and -not $otherVersion) {
Write-Host 'app is up to date'
}
else {
Write-Host "app is not installed"
}
Please sign in to leave a comment.
Comments
0 comments