question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connect-AzureAD Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly

See original GitHub issue

Steps 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:closed
  • Created 4 years ago
  • Reactions:21
  • Comments:69 (16 by maintainers)

github_iconTop GitHub Comments

38reactions
ohadschncommented, Apr 28, 2020

In short, it’s not supported in .NET Core, and therefore not in PowerShell Core (7.X).

38reactions
iSazonovcommented, Sep 3, 2019
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found