Invoking PowerShell from cmd.exe

Microsoft PowerShell is a marvelous technology, and according to some linux developers the only reason they are jealous of not working  on Windows 🙂

Being so powerfull, I wanted to use it in our build script, but unfortunately it was hard to invoke a powershell script from the command line – cmd.exe.
Surprisingly there is no command line option for executing scripts, which is obvious to me and probably  one of the most important use cases.
After struggling for a while I finally found a blog post about it and want to spread the word and maybe help someone with the same problem
So here it is:

powershell " & 'C:\path\to\script.ps1' "

Invoked with one argument in quotes, powershell executes the string as script. So the trick here is to invoke it, and use the & ‘script_file.ps1’ command to make it execute your script.

http://www.leeholmes.com/blog/RunningPowerShellScriptsFromCmdexe.aspx

Good luck everyone and happy programming!