This is a portion of my script for installing ADFS. Pretty straightforward, but it seems Start-Process is parsing switches in a funny way. Is there something I’m missing?
write-host "Installing ADFS - process should take 30-45 seconds"
$installtime=get-date -uformat "%Y_%h_%d_%H_%M"
$logfile="$pwd\adfssetup_$installtime.log"
$ADFSInstall = "AdfsSetup.exe"
$ADFSInstallParams = '/quiet /logfile '+$logfile
Start-Process $ADFSInstall $ADFSInstallParams -wait
if ({gc -path $logfile | select-string -pattern "AD FS 2.0 is already installed on this computer"} -eq $null){write-host -ForegroundColor Cyan "ADFS Installed"} Else{write-host -ForegroundColor "There was an error Installing ADFS, please check the log file: $logfile;break}
If I Execute the above script I get the following in a log file:
Microsoft.IdentityServer.Setup Error: 5124 : 6 [ 2070099085 ]: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args) at Microsoft.IdentityServer.Setup.Diagnostics.TraceLog.WriteLine(TraceEventType eventType, String msg, Object[] args)
If I execute the exact same command manually (from the output of write-host), everything works fine.
Any ideas?
Thank you.
I cant delete the question, but what I found by investigating older logs is that the error occurs even when I run the command the regular way. So the above script is actually working as intended.