To open a PowerShell window from any folder in Windows Explorer use the registry script below
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\PSOpenHere] @="PowerShell Here" [HKEY_CLASSES_ROOT\Directory\shell\PSOpenHere\command] @="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%L'"
Alternatively this can also be setup directly in PowerShell with the script below, by default there is no HKEY_CLASSES_ROOT alias in PowerShell so we have to directly address the same key under HKLM:\SOFTWARE\Classes.
# OpenHere.ps1 # Write registry keys to add a 'PowerShell Here' option to the Windows Explorer right click menu. # Create (or overwrite) the key and populate the value to appear in the menu. $pspath = "$PSHome\powershell.exe -Noexit -Nologo" New-Item HKLM:\SOFTWARE\Classes\Directory\shell\PSOpenHere -force Set-Item HKLM:\SOFTWARE\Classes\Directory\shell\PSOpenHere "PowerShell Here" New-item HKLM:\SOFTWARE\Classes\Directory\shell\PSOpenHere\command -force Set-item HKLM:\SOFTWARE\Classes\Directory\shell\PSOpenHere\command "$pspath -Command Set-Location '%L'" # An alternative to start PowerShell and set the console title to 'PowerShell' # [Microsoft.Win32.Registry]::SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\PSOpenHere\command","","$pspath -Command Set-Location '%L' ;`$Host.UI.RawUI.WindowTitle = 'PowerShell'",[Microsoft.Win32.RegistryValueKind]::ExpandString)
The command Set-Location '%L' is used to set the current directory.
Scott Hanselman also has a PowerShell Prompt Here .inf installer that will do the same thing
“Let yourself be open and life will be easier. A spoon of salt in a glass of water makes the water undrinkable. A spoon of salt in a lake is almost unnoticed” ~ Buddha
Related PowerShell Cmdlets:
Set-Location - Set the current working location.
PowerShell Prompt Here - PowerToy from Scott Hanselman.
Open Command Window - Various Shell options, André Burgaud.