Search This Blog

Thursday, January 13, 2011

Running Powershell script from command line

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 .

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.

Further references.!5A8D2641E0963A97!6058.entry


No comments:

Post a Comment