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