Add “Run with PowerShell (Admin)” Context Menu for .PS1 Files

September 29, 2018 updated by Admin Leave a reply »

How to add “Run as administrator” to PS1 file context menu in Windows 10? Before you can run PowerShell script with admin rights, you have to launch the elevated PowerShell console firstly. To simplify this process, you can add “Run with PowerShell (Admin)” to the right-click context menu for .PS1 files.

How to Add “Run with PowerShell (Admin)” Context Menu for .PS1 Files

  1. Open the Registry Editor. Paste the following registry location into the address bar, and then press Enter.

    HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell

    Right-click on the Shell key and select New->Key, name it “Run with PowerShell (Admin)“. Underneath that, create another subkey called “Command“.

  2. Select the Command subkey in the left pane, and then double-click the “(Default)” string in the right pane.

  3. Copy and paste the following command into the Value data field, and click OK.

    "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-Command" ""& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy RemoteSigned -File \"%1\"' -Verb RunAs}"

  4. Close Registry Editor. Now you should see a new context menu entry called “Run with PowerShell (Admin)” when you right-click any .PS1 script.