Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 8 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
BUT when I start a process using start-process, PSEXEC starts out of PSStudio context and thus the job ends without waiting for the actual psexec process to end:
We have had users encounter issues with PowerShell where the Start-Process cmdlet will fail to wait for the process before returning despite using the Wait parameter.
Try adding the following line to your script after calling Start-Process:
I tried adding $install.WaitForExit() with no success. We are using PowerShell v4.
Maybe the problem isn't with the Wait parameter, but because the PsExec process starts it's thread out of PowerShell Studio process tree, unlike (New-Object System.Diagnostics.Process) which creates the thread inside of it.
In the end I have chosen a different approach with executing PsExec on the remote station with invoke-command:
This is actually even better since you don't have to wait for PsExeSvc service to establish connection. We have Sysinternals on all our computers so there's no risk of running non-existant PsExec.
This topic is 8 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.