Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Start-Process ... -Wait not waiting in child script of Invoke-Command on remote computer

$
0
0

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.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>