I'm trying to pass arguments to a MSI installer:
$Servers = @("ServerOne", "ServerTwo", "ServerThree")
$InstallerArguments = @(
"/i `"$InstallerPath`"",
"/quiet",
"/log `"$LogFile`"",
"EMAILSERVER=`"$Servers[0]`"",
"DATABASESERVER=`"$Servers[1]`"",
"SHAREPOINTSERVER=`"$Servers[2]`"",
"USERNAME=`"$UserName`""
)
Reviewing the installer logfile shows the result:
Property(S): EMAILSERVER = ServerOne ServerTwo ServerThree[0]
Property(S): DATABASESERVER = ServerOne ServerTwo ServerThree[0]
Expected result:
Property(S): EMAILSERVER = ServerOne
I think I need to escape the index somehow, what is wrong with the code?
Edit (passing arguments to installer):
Start-Process -FilePath msiexec.exe -ArgumentList $InstallerArguments -Wait
$Usernamewhich is correct. The issue is passing array elements.