Is there a way to start PowerShell in a specific folder from Windows Explorer, e.g. to right-click in a folder and have an option like \"Open PowerShell in this Folder\"?
In Windows Explorer, just go to the Address Bar at the top (keyboard shortcuts: Alt+D or Ctrl+L) and type powershell
or powershell_ise
and press Enter. A PowerShell command window opens with the current directory.
I'm surprised nobody has given this answer, it's the simplest one. (Must be the year.)
Just Shift + right click in Explorer. Then you can "Open PowerShell window here".
It may be set to Command Prompt by default. If so, you can change this in the Windows 10 Settings: go to Personalization -> Taskbar and enable "Replace Command Prompt with Windows PowerShell in the menu when I right-click the start button or press Windows key+X".
As an alternative to the answer above, which requires you to type the PowerShell command (powershell.exe) each time, you can create a context menu entry just like with the "Open command window here" context menu.
There are three registry keys where these commands go. Each key controls the context menu of a different Windows Explorer object. The first one is the one you asked about:
For each of these registry keys, you can add a subkey that will add an "Open PowerShell window here" command to the context menu, just as you have an "Open command window here" context menu.
Here is a copy of my OpenPowerShellHere.reg file, which puts the command in the context menu of each of the Explorer objects, the window background, the folder, and the drive icon:
Windows Registry Editor Version 5.00
;
; Add context menu entry to Windows Explorer background
;
[HKEY_CLASSES_ROOT\Directory\Background\shell\powershell]
@="Open PowerShell window here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\Background\shell\powershell\command]
@="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'"
;
; Add context menu entry to Windows Explorer folders
;
[HKEY_CLASSES_ROOT\Directory\shell\powershell]
@="Open PowerShell window here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\powershell\command]
@="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'"
;
; Add context menu entry to Windows Explorer drive icons
;
[HKEY_CLASSES_ROOT\Drive\shell\powershell]
@="Open PowerShell window here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Drive\shell\powershell\command]
@="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'"
So, with your favorite text editor, open a new file named OpenPowerShellHere.reg. Copy the exact text of the code above, paste it into the new file, and save it. (I would have included a copy of the file, but I couldn't figure out if attachments were possible.) If you want to exclude the command from one of the entry, just comment out the appropriate section with semicolons. My comments show you each section.
After you save the file, run it by double-clicking on it. When it asks, tell it to proceed. As soon as you run it, the context menu entries will show up!
Here is my Explorer window context menu. I've highlighted the console and PowerShell commands. As you can see, you can also add a context menu entry to run an elevated command window, i.e., Run as Administrator.
Note: Context menu entries are displayed alphabetically, based on their Registry keys. The key name for the elevated command shell is "runas", which is why it comes after the PowerShell entry.
Note: If you have an explorer window open, you may need to close it and reopen it to get the changed to take effect.
Note: In Windows 7, the HKCR\Directory\Shell
does not work if you use the toolkit on the side of the explorer
(ie. Clicking Documents under the Libraries header)
you must navigate using Computer -> C: -> to -> Some -> Target -> Directory
There's a Windows Explorer extension made by the dude who makes tools for SVN that will at least open a command prompt window.
I haven't tried it yet, so I don't know if it'll do PowerShell, but I wanted to share the love with my Stack Overflow brethren:
http://tools.tortoisesvn.net/StExBar
If you're on Windows 8, or later, you can simply use the built-in File → "Open Windows PowerShell".
Or Alt + F followed by R.
By adding the registry keys below, in Windows 10, I managed to get the Open PowerShell Here option in my SHIFT + RClick
context menus.
Just copy these into a blank notepad file then save as a .reg
file and run the file to add the key and it should work from there.
Some of these other answers say to add the key into HKCR\Directory\shell but I found that for me it only worked with the keys going into HKLM\SOFTWARE\Classes\Directory\shell
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell]
"Extended"=""
"NoWorkingDirectory"=""
@="Open PowerShell here"
"Icon"="%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell\command]
@="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell]
@="Open PowerShell here"
"Extended"=""
"Icon"="%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
"NoWorkingDirectory"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell\command]
@="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%V'"