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 :

hklm\software\wow6432node\microsoft\.netframework\OnlyUseLatestCLR

14 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?

  9. betting33 says:

    She was clearly reading us all wrong. I imagine our immaculate outfits were throwing her off track — although our look was rather spoiled by the bruises on our legs from being bashed by those heavy cases.
    https://www.betting33.com

  10. syy577 says:

    Hilariously, we aligned ourselves with the dedicated backpackers who continued to shake their heads in disbelief every time we turned up at a new destination with luggage that only got heavier as we indulged in more shopping sprees.
    https://www.syy577.com

  11. dok222 says:

    Next up was Venice, our final stop. But our typically chaotic relationship with train timetables mean we missed a direct connection, opting instead to break up the journey with a few hours in Florence.
    https://www.dok222.com

  12. ccclub700 says:

    After a failed attempt at seeing Botticelli’s “The Birth of Venus”– the queue for the Uffizi Gallery was insane — we sheepishly returned to the station to await our train.
    https://www.ccclub700.com

  13. hgame79 says:

    During the course of the trip, we’d been swapping bags while on the move for no particular reason, and being the useless travelers we were, we’d opted to keep both passports in the same bag.
    https://www.hgame79.com

Leave a Reply

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

*