Saturday, July 28, 2018

Start-Process with -Credential specified may have problems with interactive programs

One user encountered a problem while using PowerShell to start a command prompt as another user. They used the -Credential parameter to pass a credentials object (acquired with Get-Credential) to the Start-Process cmdlet, but found that the resulting command prompt didn't accept keyboard input. I don't know why it's doing that, but I do have a workaround: use the .NET Framework's Process.Start method directly:

[System.Diagnostics.Process]::Start('cmd', $creds.UserName, $creds.Password, '')

No comments:

Post a Comment