Azure AD Import-Module – Could not load file or assembly

Problem

You will receive the following error when try to run the Windows Azure Active Directory Module or run the command Import-Module MSOnline on a Windows 7 or 2008 R2 machine.

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

Cause

This problem will occur due to PowerShell built against the .NET framework in a specific version. You can check it by the PowerShell variable:
$PSVersionTable.

Fix/Solution

For me the problem was solved after installing Windows Management Framework 3.0.

For more detail, you can refer this article: Azure AD Module – This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded

Advertisement

Leave a Comment