Open Powershell From Here

257

5

2

This instructable will teach you how to add a context menu option that will open PowerShell from your current location.

Step 1: Open Powershell As Administrator

Open an elevated powershell

Step 2: Paste Code

Run the following code in your elevated PowerShell window.


$menu = 'Open Windows PowerShell Here as Administrator'

$command = "$PSHOME\powershell.exe -NoExit -Command ""Set-Location '%V'"""

'directory', 'directory\background', 'drive' | ForEach-Object { New-Item -Path "Registry::HKEY_CLASSES_ROOT\$_\shell" -Name runas\command -Force | Set-ItemProperty -Name '(default)' -Value $command -PassThru | Set-ItemProperty -Path {$_.PSParentPath} -Name '(default)' -Value $menu -PassThru | Set-ItemProperty -Name HasLUAShield -Value '' }

First Time Author Contest

Participated in the
First Time Author Contest

Share

    Recommendations

    • Fandom Contest

      Fandom Contest
    • Beauty Tips Contest

      Beauty Tips Contest
    • Backyard Contest

      Backyard Contest

    2 Discussions

    0
    None
    Phoenix830

    1 year ago

    holding shift and right clicking also achieves this

    0
    None
    Swansong

    1 year ago

    Thanks for sharing :)