holidayhack

Here’s a holiday hack for PowerShell. If you would like the ability to right-click on a directory and have PowerShell open to that directory here’s what you do…

  1. Open the registry on the system you want to do this on (regedit.exe)
  2. Navigate to HKEY_CLASSES_ROOT\directory\shell

image1

  1. Right-click and create a new key called PowerShellPrompt

image2

  1. Rename the Default Data to “PoSH Here” or something similar. This is what will display in the context menu when you right-click
image3 image4
  1. Right-click on the PowerShellPrompt key and create a new key. Name it Command

image5

  1. Change the Default data to the following command-line
powershell.exe -noprofile start-process  powershell.exe -verb runas -argumentlist "{ -noprofile -noexit cd %1}

image6

  1. Now, when you right-click on a directory, An elevated PowerShell prompt will open at that directory

image9

  1. If you want to load your profile when this prompt opens, remove the second “-noprofile” from the command-line
powershell.exe -noprofile start-process  powershell.exe -verb runas -argumentlist "{ -noexit cd %1}"
  1. If you want to have an Icon show up in the Context menu add the following String value to the PowerShellPrompt key

image11 image12

Value for Value

If you received any value from reading this post, please help by becoming a supporter.

Thanks for reading,
Alain