ED209
ED209

Reputation: 638

Powershell MSI installer script

Please could somebody help me with the powershell script that I have written below? I just can not seem to get the installer to start:-

$msiName = "D:\Folder\Build 1.9.0.39621 Setup.msi”
Write-Host "Installing msi"

$argumentlist = "/i [application] /qn /l*v log.txt LOGDIR=`"D:\Log`" SQLSERVER=`"xxx-xxx-xxxx-2`" DBAUTOBACKUP=`"0`" APPPOOLDOMAIN=`"Test-as`" APPPOOLUSER=`"Testservice`" APPPOOLPASSWD=`"xxxxxxx`" ADQUERY=`"Test-as.net`" ADNAME=`"ultra`""

$application = $msiName
$argumentlist = $argumentlist.Replace("[application]",$application)

Start-Process -FilePath "C:\Windows\System32\msiexec.exe" -ArgumentList $argumentlist -Wait 

I have tried to simply it, but it still will not work. Below is a number of different ways I have tried:-

(1st Attempt)

$argumentList = "/i `"xxxxxx 1.9.0.39641 Setup.msi`""

Start-Process -FilePath "C:\Windows\system32\msiexec.exe" -ArgumentList $argumentList 

(2nd attempt)

$argumentList = "/i {0}" -f "xxxxxx 1.9.0.39641 Setup.msi"

Start-Process -FilePath "C:\Windows\system32\msiexec.exe" -ArgumentList $argumentList 

(3rd attempt)

$argumentList = ("/i {0}" -f "xxxxxx 1.9.0.39641 Setup.msi")

Start-Process -FilePath "C:\Windows\system32\msiexec.exe" -ArgumentList $argumentList 

(4th attempt)

$argumentList = ("/i {0}" -f "xxxxxx 1.9.0.39641 Setup.msi")

Start-Process -FilePath "C:\Windows\system32\msiexec.exe" -ArgumentList "$argumentList" 

Upvotes: 0

Views: 664

Answers (2)

Moerwald
Moerwald

Reputation: 11294

I deleted the old answer.

New possible solution

ArgumenList is a string array, therefore it can take multiple arguments.

Start-Process -FilePath "C:\Windows\system32\msiexec.exe" -ArgumentList "/i", "`"xxx yyyyy.msi`""

I tried it with an installer including blanks in the name, worked on my machine.

Hope that helps

Upvotes: -1

HeXDeMoN
HeXDeMoN

Reputation: 58

Here's what I used in the past , should work for you.

    $argumentList = @(
        "-o",
        "$sourcefile",
        "-d",
        "$targetFolder"
    )
start-process -filepath $file -argumentlist $argumentList -wait -nonewwindow -passthru

Upvotes: 0

Related Questions