MIM 2016 : Cannot load Azure PS Module in the PowerShell Workflow

I am using the codeplex PS workflow, but this applies to if you are using the MIM WAL PS workflow. I have a PS script that does some O365 activities, at the begining of the script I load the Msol module. The script is running in the workflow. It is not an external script that I can call from the workfow, all my script code is in the worklow.

I downloaded the latest Azure PS module and installed it. When my workflow runs I get the following error

Import-Module : Could not load file or assembly ‘file:///C:\Windows\system32\WindowsPowerShell\v1.0\Modules\MSOnline\Microsoft.Online.Administration.Automation.PSModule.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

The issue is that the newer Azure PS module are compiled in Dotnet 4.0 and greater. The MIM PS workflow is compiled in Dotnet 3.51.

Solution

A lot depends on what you are doing in O365 with your PS script. If you are not doing anything that requires a a more recent PS module you can revert back to an old Msol module. I got version 1.0.0.0 from here. Downloaded Build 8362.1. Installed it and my PS workflows worked fine, the module was successfully loaded.

If you are calling functions that are in later Azure PS modules then you have to run your PS script outside the workflow. I would not recommended the fix out there where you edit your service.config file and load the 4.0 and 2.0 runtime. I know from experience that this action will decapitate your MIM SSPR, there could be other MIM functions affected and its not supported by Msft.

Advertisements

Leave a Reply

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

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 )

Google+ photo

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

Connecting to %s