1

Azure AD Module – This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded

When attempting to run the Windows Azure Active Directory Module on a Windows 7 or 2008 R2 machine, things did not go swimmingly.  In fact they did not work at all.  The error message of “This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded” was reported. 

 

Repro Steps

The below was tested on a Windows 7 and a separate Windows Server 2008 R2 machine.  The Azure AD Module was installed along with the latest Sign In Assistant (SIA).  We can use the shortcut to get to the Azure AD PowerShell module as noted in the A Shortcut URL To Download Azure AD PowerShell post

SIA version 7.250.4556.0 was installed and then the latest Azure AD module.  When launching the shortcut to the module, the below error was logged:

Azure AD PowerShell Module - This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded

Import-Module : Could not load file or assembly 'file:///C:Windowssystem32WindowsPowerShellv1.0ModulesMSOnlineMicrosoft.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.
At line:1 char:14
+ Import-Module <<<<  MSOnline
    + CategoryInfo          : InvalidOperation: (:) [Import-Module], BadImageFormatException
    + FullyQualifiedErrorId : FormatXmlUpateException,Microsoft.PowerShell.Com   mands.ImportModuleCommand

 

OK – what about if we then  try to manually import the MSOnline module?

Azure AD PowerShell Module - This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded

Same thing.  OK, let’s take a look at the machine to see what the current build of PowerShell etc. actually is. 

 

Machine Configuration

Looking at the machine, the machine’s configuration the $PSVersionTable can show us the current version of PowerShell and Windows Remote Management (WinRM).  This is shown below:

Initial $PSVersionTable On Windows 7

$PSVersionTable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.5485
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1

 

This machine has the initial WinRM 2.0 and PowerShell 2.0 components installed, nothing newer.  This was the case for both the Windows 7 and Windows Server 2008 R2 machines,  Which reminded me of an older issue with the Directory Synchronization tool that was related:

KB 2964373 - "Could not load file or assembly" error when you run DirSyncConfigShell.psc1 in Windows Server 2008 R2

 

Windows Management Framework 3.0 was downloaded and then installed onto the machines. 

Windows Management Framework 3.0 Download

 

Installing Windows Management Framework 3.0

 

Note that I already had the .NET prerequisite version installed.  If you do not, that will need to be installed prior to installing WMF 3.0.  Then the machines were restarted. 

 

After Installing WMF 3.0

Launching the Azure AD Module is now successful, and we can connect to Azure AD using PowerShell. 

Azure AD Module Now Loading After Updating to WMF 3.0

 

 

Checking the $PSVersionTable after upgrading to WMF 3.0, we can see that the values have been incremented

$PSVersionTable After Updating to WMF 3.0

 

BootNote

We can use the step outlined in this post to check the version number of the Azure AD PowerShell module. 

The version downloaded and installed as of May 2016 was 1.0.9031.1

Checking Version Of Azure AD Module

Additional version information and history can be found in the TechNet Wiki.

 

Cheers,

Rhoderick

Rhoderick Milne [MSFT]

Leave a Reply

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