If you want to install a *.msi package by first un-installing the product and then installing, you can use the following PowerShell script:
Use System.Diagnostics.Process.Start function and the WaitForExit function to make sure the product is un-installed before it is installed.
# This scripts needs unrestricted access
Set-ExecutionPolicy Unrestricted
# Change working directory to script directory
function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
$scriptFolder = Get-ScriptDirectory
# Un-Install Database
$parameters = "/qn /x {B381D4FB-7A5C-4794-8997-8CAAF2847E20}"
$uninstallStatement = [System.Diagnostics.Process]::Start( "msiexec", $parameters )
$uninstallStatement.WaitForExit()
# Install Database
$parameters = "/qn /i " + $scriptFolder + "\Sales.Database.Setup.msi"
$installStatement = [System.Diagnostics.Process]::Start( "msiexec", $parameters )
$installStatement.WaitForExit()
Roel-
I have a .MSI file on a network share and want to uninstall and install silently as I need to deploy this via Active Directory using powershell to multiple computers across the network, I’m confused where I would replace with the network share location and actual .MSI setup file, can you let me know? I’m very new to powershell, thanks.
NETWORK LOCATION OF MSI FILE:
\\\ROOT\Installs\BlueBeam\BbRevu1100NetDeploy\SilentInstall\MSI
MSI FILENAME:
Bluebeam Revu x64 11.msi