Recently I had to try and schedule some PowerShell scripts. However running the script proved difficult.
Searching the web I found many references indicating the issue was because of spaces in the path of the script. The solution was to use the ampersand .
http://technet.microsoft.com/en-au/library/ee176949.aspx
powershell.exe &'c:\my scripts\test.ps1'
However this did not work. It would just open the PS prompt. In the end I eventually found the solution was this
powershell.exe “&'c:\my scripts\test.ps1'”
Now I believe it works because of the way parameters are split and passed to PowerShell. See this article.
http://poshoholic.com/2007/09/27/invoking-a-powershell-script-from-cmdexe-or-start-run/
Further references.
http://keithhill.spaces.live.com/blog/cns!5A8D2641E0963A97!6058.entry
No comments:
Post a Comment