I need a single command that opens a new elevated PowerShell window on a given path. why? I want a shortcut for opening Powershell as admin on given directory(just like holding shift and right-click on any directory will give you, but as admin.)
I used this to add an "open powershell window as admin here" shortcut to my right-click menu.
currently, I have
powershell -Command "Start-Process PowerShell -Verb RunAs"
that will open elevated PowerShell in C:\WINDOWS\system32 , or:
powershell.exe -noexit -command Set-Location -literalPath '%V'
that will open a new not elevated powershell window on current directory
I tried
powershell -Command "Start-Process PowerShell -Verb RunAs; Set-Location -literalPath '%V'"
but it does not navigate to the directory.
note - %v becomes the path inside the directory you right-clicked in it.
How can I combine correctly these commands to open elevated PowerShell in the wanted directory?


