Learn about Windows PowerShell
Summary: Learn how to run a script with a space in the path.
Question: How do I run a script with a space in the path?
Answer 1: PS > c:\my` folder\myscript.ps1
Answer 2: PS> &(“c:\my folder\myscript.ps1”)
Question: What is the easiest way to create an array?
Answer 1: $array = “1”,”2”,”3”,”4”
Answer 2: $array = 1..4
<p>I love the short PowerTips, thanks!</p>
<p>@Hieronymus: Me too!</p>
<p>Short, precise and easy to remmeber!</p>
<p>@Hieronymus Thank you I hope you find them beneficial. </p>
<p>@Klaus Thanks for your kind words. </p>
<p>I think you're missing a space in there:</p>
<p>Answer 1: PS > c:\my`folder\myscript.ps1</p>
<p>produces an error on my machine. but:</p>
<p>PS > c:\my' folder\myscript.ps1</p>
<p>works fine. Need to escape the space so PoSh doesn't interpret it as a separate argument or parameter. Unless I'm missing something to make the first one work?</p>
<p>And then of course I make my own typo:</p>
<p>PS > c:\my` folder\myscript.ps1</p>
<p>Apostrophe is not a grave.</p>
<p>@Angel yes, the space disappeared, and that was the entire point of the tip :-) Thanks for the catch, and I added the space back in to the command. </p>
<p>Also this works if you are executing a powershell script from a command interface and the name your script has a space in the path or file name.</p>
<p>As in powershell -noexit .\my` powershell` script.ps1</p>
You can use Long Path Tool for such problems, it works good.