Friday, 16 January 2015

ProTip: Open Powershell as admin from Powershell

Just a quick one as I find I have been using this trick a lot lately.
If I am in a standard Powershell prompt and need to get an admin one open, I used to search for Powershell, right-click, run as admin. I'd do this even if I was already in a Powershell prompt as I can never remember the syntax for runas.exe.
A much easier way, especially if you are already in a Powershell prompt is:

Start-Process powershell -verb runas

This works for any executable and will pop up UAC appropriately to allow you to enter credentials if you need to, or just run as admin if you are already an Administrator.

Hope this helps some one.


This can be further shortened to

start powershell -verb runas

Thanks anonymous user!

1 comment:

  1. To keep it as brief as possible you can use the alias start or saps in place of Start-Process:

    start powershell -verb runas