How to run Active Directory cmdlets in Orchestrator .Net Activity

March 13, 2015 Posted by Alexander Axberg

As you might have noticed, Orchestrator can be a bit grumpy when it comes to running Powershell scripts. Some cmdlets will simply not load in a .Net Script Activity.
Running scripts in a .Net Script Activity is really nice, because we have the possibility to publish variables in the script directly to the data bus.
A way around this could be to run scripts remotely on another server or add: Powershell{ /script\ } around your script, but in both cases we loose the possibility to publish all variables to the data bus.


The Problem

Orchestrator runs all powershell scripts in powershell v2 and in 32-bit mode. We can simulate this by:

  1. Starting a Powershell (x86) console
  2. Loading version 2 by typing: powershell -version 2
  3. If we try to load the cmdlets: import-module activedirectory you will see it will fail to load with some strange errors


The Cause

Active Directory cmdlets are compiled using the .Net4 assemblies, and poweshell v2 will only load .Net2 by default.
You can verify this by typing: [Environment]::version in your powershell console. “Major” is the version of the currently loaded .Net assembly.
If you compare on a regular x64 powershell console, and in a x86 v2 console like the one we started in the section above, you will see the difference.


The Solution

Add the following REG_DWORD registry key on the Orchestrator server and set the value to 1, to make Powershell (x86) always load the latest .Net assemblies :


9 Responses to How to run Active Directory cmdlets in Orchestrator .Net Activity

  1. Theodor Brander says:

    Worked like a charm. Thank u very much! we’ve until now used painful workarounds to resolve this but now we can skipp this 🙂

  2. Alex Marsh says:

    Just a note on this. The presence of this key will stop Operations Manager Console installing on the server so ensure that this is present first before adding the key.

  3. Chris Karraker says:

    Will this affect current .net scripts and make them unable to run? Or will they continue to work as normal?

  4. Parag says:

    Worked like a charm. Thank you very much.

  5. Really well written blog post! I shall definitely use some of the ideas
    myself, you’re awesome. Do you do online seminars?

  6. Seriously well written blog! I am going to definitely use somke of tthe ideas myself, you’re fantastic.
    Do you do training?

  7. Nonetheless, might I ask your form recommendation?

  8. chris says:

    Sounds good. I’ll give this a try.

    Quick question: Will this force the runbook to download/install .net4 assemblies each time a “Run Net Script Script” activity needs to import the Active Directory module?

Leave a Reply

Your email address will not be published. Required fields are marked *