Launching Applications with Alternate Credentials

by Mar 21, 2013

If you must run an application with a different identity, Start-Process offers the parameter -Credential. This would launch the Notepad editor using the context of user mydomain\myuser:

Start-Process -FilePath notepad -Credential mydomain\myuser

However, you may run into errors. When you switch user context, the application still uses your current path. If the new identity has no access permission to your current path, or your current path is a mapped network drive that is not available for the new user context, then the call fails.

That's why you should always make sure you also define a working directory that is accessible:

Start-Process -FilePath notepad -Credential mydomain\myuser -WorkingDirectory C:\

And if you want to also load the user profile, add -LoadUserProfile.

Twitter This Tip! ReTweet this Tip!