I have a PowerShell script file at C:\Path with spaces\Script.ps1.
When I try to open it in the Windows file explorer by double-clicking it with the mouse the PowerShell console opens, an exception is thrown because of the spaces in the path of the script file itself and the console gets instantly closed.
One way to solve that is to create a shortcut of PowerShell C:\Path with spaces\Run script.lnk with the file parameter -File "C:\Path with spaces\Script.ps1" and open it instead.
What I would like to know is if there is a way to allow the script to run by itself on a path that contains spaces without the need of other additional files.

& 'C:\Path with spaces\Script.ps1'Run with PowerShell? By the way, what exception is thrown exactly and by what? By default, double-click should open script in text editorps1have PowerShell as their default program to be opened with. The same exception happens if I right-click and explicitly run it with PowerShell, which looks like this. The PowerShell console gets opened, shows the exception and instantly closes.