Skip to main content
Code and think

PowerShell Runas different user

If you need to start some application (e.g. PowerShell) you can use runas command:

runas /netonly /user:mydomain\username "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"

where mydomain\username is replaced with your credentials and path to the .exe points to the application you want to start. If at the same time you want to start the app in elevated mode just execute the command from the command prompt which you run as administrator.

An alternative is to hold the SHIFT key and right-click on the application. Then select Run as different user.

BTW this is useful also when you want to connect to DB with another user from SSMS. Start SSMS under this user and then you can use that credentials to connect to the server with Windows authentication.