Prerequisites
Steps to reproduce
On Windows, when you combine Start-Process -Wait with -Credential (running as a different user), the process is launched, BUT
- an
Access denied error is reported
- no waiting occurs.
By contrast, using -PassThru and .WaitForExit() on the passed through System.Diagnostics.Process instance works fine.
# Run on Windows
# Be sure to specify valid credentials when prompted.
Start-Process -Credential (Get-Credential) cmd -Wait
Expected behavior
No error should occur, and the call should block until the launched cmd instance is exited.
Actual behavior
The cmd instance is launched, but, instead of waiting, an Access denied error is emitted.
Contrast this with this seemingly equivalent command, which works as expected:
(Start-Process -Credential (Get-Credential) cmd -PassThru).WaitForExit()
Error details
No response
Environment data
PowerShell Core 7.3.0-preview.2 on Windows
Visuals
No response
Prerequisites
Steps to reproduce
On Windows, when you combine
Start-Process -Waitwith-Credential(running as a different user), the process is launched, BUTAccess deniederror is reportedBy contrast, using
-PassThruand.WaitForExit()on the passed throughSystem.Diagnostics.Processinstance works fine.Expected behavior
No error should occur, and the call should block until the launched
cmdinstance is exited.Actual behavior
The
cmdinstance is launched, but, instead of waiting, anAccess deniederror is emitted.Contrast this with this seemingly equivalent command, which works as expected:
Error details
No response
Environment data
Visuals
No response