Open Powershell as Admin on Right-Click
I described how to set a context menu option to open a Powershell console on right click earlier.
To open Powershell as admin on right click, we can add a command to be executed on start to our registry entry like so
$stpath = pwd; Start-Process PowerShell -ArgumentList \"-NoExit\", \"-Command cd $stpath\" -verb RunAs
Command in the registry entry will look like the following
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -windowstyle hidden -Command $stpath = pwd; Start-Process PowerShell -ArgumentList \"-NoExit\", \"-Command cd $stpath\" -verb RunAs
The downside of this approach is that first a normal Powershell window is opened, which opens a new Powershell window as admin if the user has the priviledges, and then the original Powershell window closes in the background.
This results in a flicker when Powershell is run as admin.
If you find a flickerless approach to doing this, please leave a comment on this gist. Thanks!