Executing Powershell from CruiseControl.NET on 64-bit Windows

If you try to execute a Powershell script from a CruiseControl.NET build on a 64-bit OS, you’ll get the following error:

File ~filename~.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.

If you google around, you’ll be told to execute Set-ExecutionPolicy. Unfortunately, on 64-bit, that won’t fix your problem.

The issue is that CruiseControl.NET is 32-bit and the default powershell on 64-bit Windows is 64-bit. When a 32-bit process accesses SOFTWARE registry keys, the request gets redirected to HKLM\Software\Wow6432Node. This results in powershell looking for the wrong key and thus getting the default value.

To work around the problem, execute the following at an elevated command prompt:

%windir%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe “Set-ExecutionPolicy RemoteSigned”

In finding this solution it prompted me to realise that, in 64-bit Windows, c:\windows\system32 is 64-bit and c:\windows\SysWOW64 is 32-bit. And then my head exploded.

Advertisement
This entry was posted in 64-bit, cruisecontrol.net, powershell. Bookmark the permalink.

2 Responses to Executing Powershell from CruiseControl.NET on 64-bit Windows

  1. BeaKeR says:

    Richard,
    I’ve been banging my head on this exact problem for a while now – thanks for posting the fix!

    BKR

  2. hver says:

    Thank you for researching this problem and writing down your findings. I was getting hopeless.

    Han

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s