I have a script I am using a start process to run a silent install of a product.
It seems to fire off very slowly, takes about 40 seconds. If i just execute the command at the command line prompt it will go within 3 seconds.
My code has variables it is putting together to get all the correct syntax. Code is below.
If I run the code I have all the variables defined at the beginning. I can issue a Write-Host after I exit and all the variables come back correct, but.....the $argies variable comes back blank. Even though that variable comes back blank when
the executable does fire off it has all the information from the variable in the screens.
Not sure why it takes almost 40 seconds to execute with Start-Process.
Any clues from anyone ?
function Show-Menu
{
param (
[string]$Title = 'VDA Server Setup'
)
cls
Write-Host "================ $Title ================" -foregroundcolor "Green"
Write-Host
Write-Host "**************** $farm *****************" -ForegroundColor "red" -backgroundcolor "yellow"
Write-Host
Write-Host "1: Press '1' to Execute Installation." -foregroundcolor "Green"
Write-Host "Q: Press 'Q' to quit." -foregroundcolor "Green"
Write-Host
}
$controller1 = ' "ServerName1'
$controller2 = ' ServerName2"'
#Space at beginning of $controller2 is required
$dpath = "c:\source\"
$vdaexe = $dpath + 'VDAServerSetup_7_15_1000.exe'
$argies = '/noreboot /components vda /enable_hdx_ports /enable_real_time_transport /optimize /controllers' + $controller1 + $controller2
cls
do
{
Show-Menu
$input = Read-Host "Please make a selection:"
switch ($input)
{
'1' {
Write-Host
$confirmation = Read-Host 'Are you Sure You Want To Proceed (Type Yes / No ) '
if ($confirmation -eq 'YES' -Or $confirmation -eq 'Y') {
# proceed
Write-Host "Starting VDA Configuration....Please Wait...." -ForegroundColor "Cyan"
$userlogvar | out-file $usercaplog
Start-Process $vdaexe -Argumentlist $argies -workingdirectory $dpath -wait
#cmd /c $vdaexe + $args -wait
#write-host $vdaexe $args
#Write-Host $vdaexe + $installcmd
#$installcmd | out-file -filepath $cmdbatfile -Encoding
}
else
{
Write-Host "Aborting...." -ForegroundColor "Red"
Exit
}
Write-Host "VDA Install Completed!" -ForegroundColor "Green"
Write-Host
Write-Host "Server will reboot in 10 seconds!" -Backgroundcolor "Yellow" -ForegroundColor "Red"
Start-Sleep -s 10
Restart-Computer -ComputerName "localhost"
exit
} 'q' {
return
}
}
pause
}
until ($input -eq 'q')