In previous article, we mentioned How to Find WDDM Version in Windows but in this article, I have mentioned how to add or remove "open powershell here" context menu option.

Microsoft has been attempting to transition folks away from the command prompt and toward PowerShell for the past few years. As a result, Microsoft replaced the "Open Command Prompt Here" option in the Shift + Right-click context menu with "Open PowerShell Here."

Microsoft's PowerShell is a task automation and configuration management framework that includes a command-line shell and scripting language. It was originally a Windows-only component known as Windows PowerShell, but with the launch of PowerShell Core on August 18, 2016, it became open-source and cross-platform.

PowerShell, as you may know, is an open-source project that comes pre-installed with Windows 10. You may access it through the Power User menu or by using Cortana to search for it.

If you prefer Windows PowerShell over the Command Prompt, you'll appreciate the ability to access it directly from the context menu that appears when you right-click a folder in Windows. Here's how to get it done.

Unlike Command Prompt, you may open it from anywhere by holding down the Shift key and right-clicking the folder; from the context menu, select Open Command Window Here. However, there is no possibility to open a PowerShell window here. At this point, you must manually add the item to the context menu.

1.png

 

If you prefer PowerShell, you may either start PowerShell and navigate to the folder from there or use the command from the File Explorer menu.

Instead, why not add an option to the same context menu that says "Open PowerShell window here"? It's simple to accomplish. You only need to make a few minor changes to the Windows Registry.

Any program with a lot of options for easy and efficient operation can have a context menu. We'll teach you how to quickly add PowerShell to the context in this post.

Steps to Add "Open PowerShell" On right-click Context Menu

Follow the below steps:

  • Open Registry Editor by searching it in the search bar. Press the Enter button to open it. Allow it to make changes to your computer.

2.png

  • Use the left sidebar of the Registry Editor to browse to the following key:

3.png

  • After that, you'll make a new key within the shell key. Choose New > Key from the context menu when you right-click on the shell key, "powershellmenu" is the new key's name.

4.png

  • Now, inside the new powershellmenu key, update the (Default) value. Double-click the (Default) value to launch its properties window while holding down the powershellmenu key.
  • After that, you'll need to make a new key within your powershellmenu key. Choose New > Key from the context menu when you right-click the powershellmenu key. The new key should be named "command."

5.png

  • You'll now modify the (Default) value within the new command key. Double-click the (Default) value to open its properties window while holding down the command key.
  • Click "OK" after typing the following text into the "Value data" box.

C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%L'

7.png

  • The modifications should take effect right away, allowing you to quit Registry Editor. To try it out, right-click any folder and select the "Open with PowerShell" command (or Shift+right-click if you enabled that option).

8.png

  • The PowerShell window should launch quickly and place you inside the folder you right-clicked after a few moments.

Simply go back into the Registry and delete the powershellmenu key you generated if you wish to undo the modifications at any point. This will remove the command from your context menu and delete any values and other keys you created inside the powershellmenu key. This is the easiest and the simplest way to Add “Open PowerShell Here” to the Right-Click Menu for a Folder in Windows.

Add "Open Powershell here as Administrator" using Powershell.

We can also add "Open Powershell here as Administrator" context menu in Windows 10 or Windows 11, using powershell script below, just open your windows powershell as an administrator first and then use below script

$menu = 'Open Windows PowerShell Here as Administrator'
$command = "$PSHOME\powershell.exe -NoExit -NoProfile -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 ''
}

Executing above scripts, changes registery settings and it will create new entry on the context menu "Open powershell here as administrator".

How to Remove "Open PowerShell" from right-click Content Menu

  • To open the Run command, press the Windows key + R keyboard shortcut. Hit Enter after typing regedit.

r1.JPG

  • In the Registry Editor window that displays, navigate to the following location: HKEY_CLASSES_ROOT\Directory\shell\Powershell
  • The "Powershell" key is protected by default, and none of its values can be changed. You must claim ownership of this registry key and grant your account complete permissions.
  • Right-click the "Powershell" key in the left pane and then select New -> String Value.
  • Make a new string called "ProgrammaticAccessOnly" with no value data.
  • You've now successfully deleted "Open PowerShell window here" from the context menu when you right-click any folder while holding SHIFT.

Simply erase the ProgrammaticAccessOnly entry from the aforementioned registry locations whenever you need to restore the "Open PowerShell window here" context menu.

The good news is that you can simply restore the removed option with a simple registry change while still using PowerShell. This provides you the freedom to play on whatever console you desire.

That is all there is to it. Adding the Command Prompt option to the right-click context menu is that simple.

PowerShell is a good command prompt substitute, but it is not for everyone. This is especially true if you've been using the command prompt for a long period.

You may also like to read:

How to Find WDDM Version in Windows

How to Check If Windows 10 Is Genuine or Not

Windows Version List