I've been trying to open PowerShell directly from the context menu in Windows 11, but I'm running into an error. Whenever I select 'Open PowerShell window here' after shift-right-clicking, I get this error message: "Set-Location : A positional parameter cannot be found that accepts argument 'folder'." It specifies an issue with my command, particularly when trying to set the location to a folder on my desktop. I've already tweaked some registry keys located at HKEY_CLASSES_ROOTDirectoryshellPowershellcommand but it hasn't worked. Is there another registry key I may need to adjust? Interestingly, if I just right-click and choose 'Open in terminal', the PowerShell terminal opens up fine. I think the recent registry hack I performed to revert to the old right-click menu might be contributing to the problem.
3 Answers
I encountered a similar problem a while back and found a script that might help you fix this. Check out this tool: [Repair-PowershellContextMenu.ps1](https://github.com/krzydoug/Tools/blob/master/Repair-PowershellContextMenu.ps1). It worked for someone else on another forum, so it could do the trick for you too!
It seems like the issue might be related to how the path is quoted in your registry settings. Make sure you’re using the right syntax for paths that have spaces, which means it should look something like this: `powershell.exe -NoExit -Command "Set-Location -LiteralPath '%V'"`. Double-check that your quotes and arguments match exactly; that could be causing the error you’re seeing.
Instead of using `Set-Location`, consider using `pushd` to change directories. It's basically an alias for `Set-Location`, but it could behave differently in your case. Also, be sure to wrap your path in quotes: "C:pathtoNew Folder". The space in your path is likely the problem here.
Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures