1
votes

I am getting the below error when importing the "AzureAD" powershell module. I have installed the module, unable to import it. I have checked to see if there are any prerequisites required, nothing mentioned in GitHub.

Earlier, I was able to install and import "AZ" module.

UPDATE : Resolved one dependency by copying the system.windows.forms.dll, but more runtime errors... enter image description here

Name                           Value
----                           -----
PSVersion                      6.2.3
PSEdition                      Core
GitCommitId                    6.2.3
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\AzureAd\2.0.2.76\AzureAd.psd1'. VERBOSE: Loading 'FormatsToProcess' from path 'C:\Program Files\PowerShell\Modules\AzureAd\2.0.2.76\AzureAD.Format.ps1xml'. VERBOSE: Populating RepositorySourceLocation property for module AzureAd. VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\AzureAd\2.0.2.76\Microsoft.Open.Azure.AD.CommonLibrary.dll'. Import-Module : Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified. At line:1 char:1 + Import-Module -Name AzureAd -Scope Global -Verbose + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand

2
delete the azuread module completely with explorer and reinstall it?4c74356b41
Yes, have tried it..did not help. have also removed multiple copies of the azuread module and installed the latest 2.0.2.7 version.jcm
I get the same error even with AzureADPreview module.jcm

2 Answers

0
votes

Which .NET version are you using? You may need to update it as this was an issue with older versions. If that doesn't work you can remove the dependency on System.Runtime.InteropServices.RuntimeInformation to get rid of the error in your screenshot.

0
votes

It seems that the AzureAD Module is not compatible with PowerShell Core due to the WinForms dependency. I have tried both 7.0.0 and 6.2.4 which did not work

However you can install it using the Desktop version of PowerShell. This version works for me.

PS C:\Windows\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.18362.752
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.752
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Run elevated

Install-Module AzureAD

And then move on...

Import-Module -Name AzureAD

$creds = Get-Credential -Message "Credentials to connect to Azure AD"
Connect-AzureAD -Credential $creds

Get-AzureADCurrentSessionInfo