I wanted to run a powershell script (in a Deployment Server job) that takes the computername as an argument. For whatever reason, I couldn't figure out how to modify the "common" method ( https://www-secure.symantec.com/connect/blogs/run-powershell-scripts-through-deployment-server ) to accept an argument. A nice guy suggested that I use psexec ( http://technet.microsoft.com/en-us/sysinternals/bb897553 ) with the interactive switch. IIRC, this worked, but since my DS box is running Windows 2008R2, a message pops up about a window in another session. When you kick off Powershell scripts using PSExec without the interactive switch, powershell will wait around for input (effectively hanging). That wasn't acceptable, so searched and found a workaround: http://www.leeholmes.com/blog/2007/10/02/using-powershell-and-psexec-to-invoke-expressions-on-remote-computers/ . This is what I came up with.
First, make sure that your powershell execution policy is set to enable scripts to be run on your DS. Type get-help about_execution_policies at the powershell prompt to learn more.
Also, make sure that you've run PSExec.exe once on your DS, so that you can accept the EULA, or use the PSExec switch to bypass this.
I created a CMD file that I run in a DS task that looks like: