I am using the following code to run a script that exists on a remote computer:
$Sess = New-PSSession -ComputerName $Computers Invoke-Command -Session $Sess -ScriptBlock {Start-Process -FilePath powershell.exe -ArgumentList "C:\Temp\BuildFiles\PreRequisiteInstall.ps1"} -AsJob
$Computers is an array of computer names.
This successfully runs the script on the remote computer. However, I have several start-process... -wait commands like the following:
Start-Process -FilePath powershell.exe -ArgumentList "$SourceDir\ServerRolesFeatures.ps1" -Wait
that do not wait. If I run the script directly on the local computer they wait. I'd like to be able to run this remotely on several computers and I shouldn't have to add get-process checks and balances, I would expect -Wait to wait.