jcm
jcm

Reputation: 43

Powershell 6.2.3 unable to import AzureAd module

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

Upvotes: 1

Views: 3067

Answers (3)

Depal Dhir
Depal Dhir

Reputation: 1

This module does not support PowerShell Core edition. Retry the operation with PowerShell Desktop edition (Windows PowerShell).

Upvotes: 0

Matthias Güntert
Matthias Güntert

Reputation: 4668

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 

Upvotes: 0

Marilee Turscak - MSFT
Marilee Turscak - MSFT

Reputation: 7728

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.

Upvotes: 0

Related Questions