title: How to get Hudson CI to execute a Powershell script?
body: <p>I'm using <strong>Hudson version 1.324</strong> for CI and have a couple of issues:</p>
  
  <p>Environment:</p>
  
  <ul>
  <li>Windows Server 2008</li>
  <li>Powershell v1.0</li>
  <li>Hudson 1.324 running as a service</li>
  <li>Hudson Powershell Plugin installed</li>
  <li>Psake (aka. "Powershell Make/Rake" available from Github) 0.23
  (All current/latest versions as of this initial post)</li>
  </ul>
  
  <p>I have a Powershell (PS) script that works to compile, run NUnit tests, and if successful, create a 7z file of the output. The PS script works from the command line, on both my local development box as well as the CI server where Hudson is installed.</p>
  
  <p><strong>1) Execution Policy with Powershell.</strong></p>
  
  <p>I initially ran a PS console on the server, ran <code>Set-ExecutionPolicy Unrestricted</code>, which allows any script to be run. (Yes, I realize the security concerns here, I'm trying to get something to work and Unrestricted should remove the security issues so I can focus on other problems.)</p>
  
  <p>[This worked, and allowed me to fire off the PS build script from Hudson yesterday. I then encountered another problem, but we'll discuss that more in item #2.]</p>
  
  <p>Once Hudson could fire off a PS script, it complained with the following error:</p>
  
  <blockquote>
    <p>"C:\Windows\system32\WindowsPowerShell\v1.0\powershell "&amp;
    'OzSystems.Tools\psake\psake.ps1' '.\oz-build.ps1'"  The term
    'OzSystems.Tools\psake\psake.ps1' is not recognized as a cmdlet, funct
    ion, operable program, or script file. Verify the term and try again.
    At line:1 char:2
    + &amp;  &lt;&lt;&lt;&lt; 'OzSystems.Tools\psake\psake.ps1' '.\oz-build.ps1'"</p>
  </blockquote>
  
  <p>Using the same command line, I am able to successfully execute the PS script from the command line manually. However Hudson is unable to get PS to do the same. After looking at additional PS documentation I also tried this:</p>
  
  <pre><code>"&amp; 'OzSystems.Tools\psake\psake.ps1' '.\oz-build.ps1'"
  </code></pre>
  
  <p>and got a similar error. There does not appear to be any documentation for the Powershell plugin for Hudson. I've gone through all the Powershell plugin files and don't see anything that's configurable. I can't find a log file for Hudson to get additional information.</p>
  
  <p>Can anyone help me past this?</p>
  
  <p><strong>2)</strong> I spent yesterday wrestling with #1. I came in this AM and tried to dig in again, after restarting the Hudson server/service, and now it appears that the ExecutionPolicy has been reset to Restricted. I did what worked yesterday, opened a PS console and <code>Set-ExecutionPolicy</code> to <code>Unrestricted</code>. It shows <code>Unrestricted</code> in the PS console, but Hudson says that it doesn't have rights to execution PS scripts. I reopened a new PS console and confirmed that the <code>ExecutionPolicy</code> is still <code>Unrestriced</code> -- it is. But Hudson evidently is not aware of this change. Restarting Hudson service again does not change Hudson's view of the policy.</p>
  
  <p>Does anyone know what's going on here?</p>
  
  <p>Thanks, Derek</p>