Powershell: Exchange Online - Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core

Created on 14 Nov 2019  Â·  12Comments  Â·  Source: PowerShell/PowerShell

New-ExoPSSession: C:\Usersteel\AppData\Local\Apps\2.0\VWJ96B25.HYQ\EEDET5OC.WPM\micr..tion_1975b8453054a2b5_0010.0000_10d85008035862c6\CreateExoPSSession.ps1
Line |
292 | $PSSession = New-ExoPSSession -UserPrincipalName $UserPrincipalName.Value -ConnectionUri $ConnectionUri -AzureADAuthorizationEndpointUri $AzureADAuthorizationEndpointUri -PSSessionOption $PSSessionOption -Credential $Credential.Value -BypassMailboxAnchoring:$BypassMailboxAnchoring
| ^ Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Resolution-Answered Resolution-External

Most helpful comment

That assembly isn't supported in .NET Core (dotnet/corefx#27126). We've been talking to the Exchange Online team to make their cmdlets PS7 compatible. Work will happen, but it's up to them.

There are multiple closed issues regarding AzureRM and AzureAD that are getting the same error as described here. Are you saying that Microsoft is "talking" to each of those teams to make their cmdlets compatible with PS7? It doesn't look like anyone is really handling the AzureAD issue. I see there is a upgrade path to AzureRM - but what about AzureAD?

All 12 comments

That assembly isn't supported in .NET Core (https://github.com/dotnet/corefx/issues/27126). We've been talking to the Exchange Online team to make their cmdlets PS7 compatible. Work will happen, but it's up to them.

Ok, thx for the info!
I so much wanted to do parallels in my Exo function :)

That assembly isn't supported in .NET Core (dotnet/corefx#27126). We've been talking to the Exchange Online team to make their cmdlets PS7 compatible. Work will happen, but it's up to them.

There are multiple closed issues regarding AzureRM and AzureAD that are getting the same error as described here. Are you saying that Microsoft is "talking" to each of those teams to make their cmdlets compatible with PS7? It doesn't look like anyone is really handling the AzureAD issue. I see there is a upgrade path to AzureRM - but what about AzureAD?

@cameronove there are on-going discussions about AAD PowerShell support. Nothing to announce yet.

Note that partial support is available using the following preview package: https://www.poshtestgallery.com/packages/AzureAD.Standard.Preview/0.1.599.7

Register-PackageSource -Name PoshTestGallery -Location https://www.poshtestgallery.com/api/v2/ -ProviderName PowerShellGet
Install-Module -Name AzureAD.Standard.Preview -Repository PoshTestGallery
Azure Active Directory .NetStandard Preview Module. This is a Private Preview release of Azure Active Directory .NetStandard Module, available in PSGallery Internal only.

Have same issue here. Frustrating to see that teams within Microsoft cannot make 1 working functionality and for every module or piece of code you have to Google how to fix it.

I use powershell just once a year, and everytime issues...

My 2 cents.

Connect-MsolService -Credential $credential
Connect-MsolService: Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Did my thing with old versions..
PS C:\WINDOWS\system32> (Get-Host).Version

Major Minor Build Revision


5 1 19041 1

I feel it is due to double authenticatoin account...

same on the the stable release of PS Core 7.0.3.

image

Import-Module ExchnageOnlineManagement -UseWindowsPowershell is the only way around this for now as Exchange Team has not updated their module to work compatibly with Powershell Core versions

You could instead try to use the az rest invoking the graph api.

Until the time az-cli is in par with the AzureAD powershell module you can instead use the graph api

az login --tenant <tenantname.onmicrosoft.com>
$uri = "https://graph.microsoft.com/v1.0/applications"

$allApplications = az rest `
   --method GET `
   --uri $uri `
   --headers 'Content-Type=application/json' | convertfrom-json

$allApplications.value |% {"{0}-{1}" -f $_.appid, $_.displayname}

I have put some samples using az rest here,
https://github.com/joepaulk/utilities/blob/master/manage-azuread-applicationregistrations.ps1

You may also refer to: https://damienbod.com/2020/06/22/using-azure-cli-to-create-azure-app-registrations/ from where i picked up inspiration

Other reference, how az rest use the accesstokens from az cli can be found here,
https://mikhail.io/2019/07/how-azure-cli-manages-access-tokens/

GitHub
code for utlities. Contribute to joepaulk/utilities development by creating an account on GitHub.
Software Engineering
This blog shows how to setup Azure App Registrations using Azure CLI and Powershell. The scripts setup the configuration for the applications created in the previous posts in this serious. The aim …
Azure CLI is a powerful tool to manage your cloud resources. Where does it store the sensitive information and why might you want to care?
Was this page helpful?
0 / 5 - 0 ratings