Connect-AzureAD Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly
See original GitHub issueSteps to reproduce
after importing AzureAd module and Calling the Connect-AzureAd Cmdlet
an interactive form opens to supply credentials and provide MFA authentication
Install-Module -Name "AzureAD" -Verbose -Force -AllowClobber
Import-Module -Name "AzureAD" -Verbose -Force
Get-Module -Name "AzureAD"-ListAvailable | Select-object Name, Version
Connect-AzureAD
Expected behavior
The Connect-AzureAd Cmdlet should continue successfully and establish a connection with Azure AD
Actual behavior
connect-azuread : One or more errors occurred. (Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.): Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
At line:1 char:1
+ connect-azuread
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : AuthenticationError: (:) [Connect-AzureAD], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Connect-AzureAD,Microsoft.Open.Azure.AD.CommonLibrary.ConnectAzureAD
connect-azuread : One or more errors occurred. (Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.)
At line:1 char:1
+ connect-azuread
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : AuthenticationError: (:) [Connect-AzureAD], AggregateException
+ FullyQualifiedErrorId : Connect-AzureAD,Microsoft.Open.Azure.AD.CommonLibrary.ConnectAzureAD
connect-azuread : Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
At line:1 char:1
+ connect-azuread
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : AuthenticationError: (:) [Connect-AzureAD], TypeLoadException
+ FullyQualifiedErrorId : Connect-AzureAD,Microsoft.Open.Azure.AD.CommonLibrary.ConnectAzureAD
connect-azuread : One or more errors occurred. (Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.): Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
At line:1 char:1
+ connect-azuread
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-AzureAD], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Microsoft.Open.Azure.AD.CommonLibrary.AadAuthenticationFailedException,Microsoft.Open.Azure.AD.CommonLibrary.ConnectAzureAD
Environment data
Name Value
---- -----
PSVersion 7.0.0-preview.3
PSEdition Core
GitCommitId 7.0.0-preview.3
OS Microsoft Windows 10.0.18362
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:21
- Comments:69 (16 by maintainers)
Top Results From Across the Web
powershell login error - Microsoft Q&A
Connect -AzureAD: One or more errors occurred. (Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.
Read more >Connect-AzureAd fails in PowerShell version 7 with
Connect -AzureAD: Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, ...
Read more >PowerShell 7.2.7 and Could not load type 'System.Security ...
Generating the problem with Connect-AzureAD module * installed and you want to install Azure AD module and connect to Azure AD, the install ......
Read more >Could not load type 'System.Security.Cryptography. ...
Trying to use azure functions to run an Exchange update powershell script. When using this command: Connect-ExchangeOnline -AppId $appId ...
Read more >Connect-AzureAD: One or more errors occurred. Could not ...
Connect -AzureAD: Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In short, it’s not supported in .NET Core, and therefore not in PowerShell Core (7.X).
@aollivierre Please move the issue to Azure feedback site. Perhaps it is here https://feedback.azure.com/forums/169401-azure-active-directory