Connect-AzureRMAccount : Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Description
When I try to use Connect-AzureRMAccount with a Service Principal I get the following Error: Connect-AzureRMAccount : Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
I've replaced the sensitive information of my ClientId, ClientSecret, and TenantId with the word 'REPLACED' in the information below. These are valid values when I run it on my machine. This is from a windows 2012 machine, when I run the same series commands on Linux everything works.
Script/Steps for Reproduction
$ClientId = 'REPLACED'
$ClientSecret= 'REPLACED'
$TenantId = 'REPLACED'
$DebugPreference = "Continue"
$SecurePassword = $clientSecret | ConvertTo-SecureString -AsPlainText -Force
$Credential = new-object -typename System.Management.Automation.PSCredential -ArgumentList $ClientId, $SecurePassword
Connect-AzureRMAccount -credential $Credential -Tenant $TenantId -ServicePrincipal
Module Version
Get-Module -Name AzureRM -ListAvailable
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 6.7.0 AzureRM
Environment Data
$PSVersionTable
Name Value
---- -----
PSVersion 6.0.4
PSEdition Core
GitCommitId v6.0.4
OS Microsoft Windows 6.3.9600
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Debug Output
DEBUG: 1:16:53 PM - ConnectAzureRmAccountCommand begin processing with ParameterSet 'ServicePrincipalWithSubscriptionId'.
DEBUG: 1:16:53 PM - Autosave setting from startup session: 'CurrentUser'
DEBUG: 1:16:53 PM - No autosave setting detected in environment variable 'AzureRmContextAutoSave'.
DEBUG: 1:16:53 PM - Using Autosave scope 'CurrentUser'
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: 'REPLACED', Endpoint: 'https://login.microsoftonline.com/', ClientId: 'REPLACED', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri:
'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 08/20/2018 17:16:53: d0d7f369-2f39-4cac-99bb-575a7f64ae20 - AcquireTokenHandlerBase: === Token Acquisition started:
Authority: https://login.microsoftonline.com/REPLACED/
Resource: https://management.core.windows.net/
ClientId: REPLACED
CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (1 items)
Authentication Target: Client
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 08/20/2018 17:16:53: d0d7f369-2f39-4cac-99bb-575a7f64ae20 - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 08/20/2018 17:16:53: d0d7f369-2f39-4cac-99bb-575a7f64ae20 - TokenCache: An item matching the requested resource was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 08/20/2018 17:16:53: d0d7f369-2f39-4cac-99bb-575a7f64ae20 - TokenCache: 35.931126885 minutes left until token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 08/20/2018 17:16:53: d0d7f369-2f39-4cac-99bb-575a7f64ae20 - TokenCache: A matching item
(access token or refresh token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Error: 4 :
DEBUG: 08/20/2018 17:16:53: d0d7f369-2f39-4cac-99bb-575a7f64ae20 - <RunAsync>d__0: System.TypeLoadException: Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformSpecificHelper.CreateSha256Hash(String input)
at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.LogReturnedToken(AuthenticationResult result)
at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.PostRunAsync(AuthenticationResult result)
at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<RunAsync>d__0.MoveNext()
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 08/20/2018 17:16:53: - TokenCache: Serializing token cache with 1 items.
Connect-AzureRMAccount : Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
At C:\Users\sfibich\Source\Repos\powershell-awg\main.ps1:13 char:1
+ Connect-AzureRMAccount -credential $Credential -Tenant $TenantId -Ser ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Connect-AzureRmAccount], TypeLoadException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
DEBUG: AzureQoSEvent: CommandName - Connect-AzureRmAccount; IsSuccess - False; Duration - 00:00:00.0502413; Exception - System.TypeLoadException: Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.RunAsyncTask[T](Task`1 task)
at Microsoft.Azure.Commands.Common.Authentication.ServicePrincipalTokenProvider.GetAccessToken(AdalConfiguration config, String promptBehavior, Action`1 promptAction, String userId, SecureString password, String credentialType)
at Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.Authenticate(IAzureAccount account, IAzureEnvironment environment, String tenant, SecureString password,
String promptBehavior, Action`1 promptAction, IAzureTokenCache tokenCache, String resourceId)
at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.AcquireAccessToken(IAzureAccount account, IAzureEnvironment environment, String tenantId, SecureString password, String
promptBehavior, Action`1 promptAction)
at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.Login(IAzureAccount account, IAzureEnvironment environment, String tenantId, String subscriptionId, String subscriptionName, SecureString password, Boolean skipValidation, Action`1 promptAction, String name, Boolean shouldPopulateContextList)
at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass87_0.<ExecuteCmdlet>b__0(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
at Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2 contextAction)
at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3 setContextAction)
at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 1:16:54 PM - ConnectAzureRmAccountCommand end processing.
DEBUG: 1:16:54 PM - ConnectAzureRmAccountCommand end processing.
If you notice in Get-Modules AzureRM has not exported any cmdlets. This means there was an import error.
What happens if you do,
Import-Module AzureRM.Profile -Verbose
Import-Module AzureRM.Resources -Verbose
If no error try,
Import-Module AzureRM -Versbose
Looks fine for the first two, the third has errors. I haven't looked into the errors just wanted to post it asap, looking now, let me know if you see something that stands out.
Details:
PS C:\Users\sfibich\Source\Repos\powershell-awg> Import-Module AzureRM.Profile -Verbose
VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\AzureRM.Profile\5.4.0\AzureRM.Profile.psd1'.
VERBOSE: Importing cmdlet 'Add-AzureRmEnvironment'.
VERBOSE: Importing cmdlet 'Clear-AzureRmContext'.
VERBOSE: Importing cmdlet 'Clear-AzureRmDefault'.
VERBOSE: Importing cmdlet 'Connect-AzureRmAccount'.
VERBOSE: Importing cmdlet 'Disable-AzureRmContextAutosave'.
VERBOSE: Importing cmdlet 'Disable-AzureRmDataCollection'.
VERBOSE: Importing cmdlet 'Disconnect-AzureRmAccount'.
VERBOSE: Importing cmdlet 'Enable-AzureRmContextAutosave'.
VERBOSE: Importing cmdlet 'Enable-AzureRmDataCollection'.
VERBOSE: Importing cmdlet 'Get-AzureRmContext'.
VERBOSE: Importing cmdlet 'Get-AzureRmContextAutosaveSetting'.
VERBOSE: Importing cmdlet 'Get-AzureRmDefault'.
VERBOSE: Importing cmdlet 'Get-AzureRmEnvironment'.
VERBOSE: Importing cmdlet 'Get-AzureRmSubscription'.
VERBOSE: Importing cmdlet 'Get-AzureRmTenant'.
VERBOSE: Importing cmdlet 'Import-AzureRmContext'.
VERBOSE: Importing cmdlet 'Remove-AzureRmContext'.
VERBOSE: Importing cmdlet 'Remove-AzureRmEnvironment'.
VERBOSE: Importing cmdlet 'Rename-AzureRmContext'.
VERBOSE: Importing cmdlet 'Resolve-AzureRmError'.
VERBOSE: Importing cmdlet 'Save-AzureRmContext'.
VERBOSE: Importing cmdlet 'Select-AzureRmContext'.
VERBOSE: Importing cmdlet 'Send-Feedback'.
VERBOSE: Importing cmdlet 'Set-AzureRmContext'.
VERBOSE: Importing cmdlet 'Set-AzureRmDefault'.
VERBOSE: Importing cmdlet 'Set-AzureRmEnvironment'.
VERBOSE: Importing alias 'Add-AzureRmAccount'.
VERBOSE: Importing alias 'Login-AzAccount'.
VERBOSE: Importing alias 'Login-AzureRmAccount'.
VERBOSE: Importing alias 'Logout-AzAccount'.
VERBOSE: Importing alias 'Logout-AzureRmAccount'.
VERBOSE: Importing alias 'Remove-AzureRmAccount'.
VERBOSE: Importing alias 'Resolve-Error'.
VERBOSE: Importing alias 'Save-AzureRmProfile'.
VERBOSE: Importing alias 'Select-AzureRmSubscription'.
PS C:\Users\sfibich\Source\Repos\powershell-awg> Import-Module AzureRM.Resources -Verbos
VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\AzureRM.Resources\6.4.0\AzureRM.Resources.psd1'.
VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\AzureRM.Resources\6.4.0\Microsoft.Azure.Management.ResourceManager.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\AzureRM.Resources\6.4.0\Microsoft.Azure.Management.ResourceManager.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\AzureRM.Resources\6.4.0\Microsoft.Azure.Management.Authorization.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\AzureRM.Resources\6.4.0\Microsoft.Azure.Management.Authorization.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\AzureRM.Resources\6.4.0\Microsoft.Azure.Management.ManagementGroups.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\AzureRM.Resources\6.4.0\Microsoft.Azure.Management.ManagementGroups.dll'.
VERBOSE: Loading 'TypesToProcess' from path 'C:\Program Files\PowerShell\Modules\AzureRM.Resources\6.4.0\Microsoft.Azure.Commands.ResourceManager.Cmdlets.Types.ps1xml'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Program Files\PowerShell\Modules\AzureRM.Resources\6.4.0\Microsoft.Azure.Commands.Resources.format.ps1xml'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Program Files\PowerShell\Modules\AzureRM.Resources\6.4.0\Microsoft.Azure.Commands.ResourceManager.Cmdlets.format.ps1xml'.
VERBOSE: Populating RepositorySourceLocation property for module AzureRM.Resources.
VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\AzureRM.Resources\6.4.0\AzureRM.Resources.psm1'.
VERBOSE: Exporting cmdlet 'Get-AzureRmProviderOperation'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmRoleAssignment'.
VERBOSE: Exporting cmdlet 'Get-AzureRmRoleAssignment'.
VERBOSE: Exporting cmdlet 'New-AzureRmRoleAssignment'.
VERBOSE: Exporting cmdlet 'Get-AzureRmRoleDefinition'.
VERBOSE: Exporting cmdlet 'New-AzureRmRoleDefinition'.
VERBOSE: Exporting cmdlet 'Set-AzureRmRoleDefinition'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmRoleDefinition'.
VERBOSE: Exporting cmdlet 'Get-AzureRmManagementGroup'.
VERBOSE: Exporting cmdlet 'New-AzureRmManagementGroup'.
VERBOSE: Exporting cmdlet 'New-AzureRmManagementGroupSubscription'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmManagementGroup'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmManagementGroupSubscription'.
VERBOSE: Exporting cmdlet 'Update-AzureRmManagementGroup'.
VERBOSE: Exporting cmdlet 'Add-AzureRmADGroupMember'.
VERBOSE: Exporting cmdlet 'Get-AzureRmADAppCredential'.
VERBOSE: Exporting cmdlet 'Get-AzureRmADApplication'.
VERBOSE: Exporting cmdlet 'Get-AzureRmADGroupMember'.
VERBOSE: Exporting cmdlet 'Get-AzureRmADGroup'.
VERBOSE: Exporting cmdlet 'Get-AzureRmADServicePrincipal'.
VERBOSE: Exporting cmdlet 'Get-AzureRmADSpCredential'.
VERBOSE: Exporting cmdlet 'Get-AzureRmADUser'.
VERBOSE: Exporting cmdlet 'New-AzureRmADAppCredential'.
VERBOSE: Exporting cmdlet 'New-AzureRmADGroup'.
VERBOSE: Exporting cmdlet 'New-AzureRmADSpCredential'.
VERBOSE: Exporting cmdlet 'New-AzureRmADUser'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmADAppCredential'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmADApplication'.
VERBOSE: Exporting cmdlet 'New-AzureRmADApplication'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmADGroup'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmADGroupMember'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmADServicePrincipal'.
VERBOSE: Exporting cmdlet 'New-AzureRmADServicePrincipal'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmADSpCredential'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmADUser'.
VERBOSE: Exporting cmdlet 'Update-AzureRmADApplication'.
VERBOSE: Exporting cmdlet 'Update-AzureRmADServicePrincipal'.
VERBOSE: Exporting cmdlet 'Update-AzureRmADUser'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmResourceGroup'.
VERBOSE: Exporting cmdlet 'Get-AzureRmDeployment'.
VERBOSE: Exporting cmdlet 'Get-AzureRmDeploymentOperation'.
VERBOSE: Exporting cmdlet 'New-AzureRmDeployment'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmDeployment'.
VERBOSE: Exporting cmdlet 'Save-AzureRmDeploymentTemplate'.
VERBOSE: Exporting cmdlet 'Stop-AzureRmDeployment'.
VERBOSE: Exporting cmdlet 'Test-AzureRmDeployment'.
VERBOSE: Exporting cmdlet 'Get-AzureRmProviderFeature'.
VERBOSE: Exporting cmdlet 'Register-AzureRmProviderFeature'.
VERBOSE: Exporting cmdlet 'Get-AzureRmLocation'.
VERBOSE: Exporting cmdlet 'Get-AzureRmManagedApplication'.
VERBOSE: Exporting cmdlet 'Get-AzureRmManagedApplicationDefinition'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmManagedApplication'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmManagedApplicationDefinition'.
VERBOSE: Exporting cmdlet 'Set-AzureRmManagedApplicationDefinition'.
VERBOSE: Exporting cmdlet 'Set-AzureRmManagedApplication'.
VERBOSE: Exporting cmdlet 'New-AzureRmManagedApplicationDefinition'.
VERBOSE: Exporting cmdlet 'New-AzureRmManagedApplication'.
VERBOSE: Exporting cmdlet 'Get-AzureRmPolicySetDefinition'.
VERBOSE: Exporting cmdlet 'New-AzureRmPolicySetDefinition'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmPolicySetDefinition'.
VERBOSE: Exporting cmdlet 'Set-AzureRmPolicySetDefinition'.
VERBOSE: Exporting cmdlet 'Export-AzureRmResourceGroup'.
VERBOSE: Exporting cmdlet 'Get-AzureRmResourceProvider'.
VERBOSE: Exporting cmdlet 'Register-AzureRmResourceProvider'.
VERBOSE: Exporting cmdlet 'Unregister-AzureRmResourceProvider'.
VERBOSE: Exporting cmdlet 'Get-AzureRmResourceGroupDeployment'.
VERBOSE: Exporting cmdlet 'New-AzureRmResourceGroupDeployment'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmResourceGroupDeployment'.
VERBOSE: Exporting cmdlet 'Stop-AzureRmResourceGroupDeployment'.
VERBOSE: Exporting cmdlet 'Test-AzureRmResourceGroupDeployment'.
VERBOSE: Exporting cmdlet 'Set-AzureRmResourceGroup'.
VERBOSE: Exporting cmdlet 'New-AzureRmResourceGroup'.
VERBOSE: Exporting cmdlet 'Get-AzureRmResourceGroup'.
VERBOSE: Exporting cmdlet 'Save-AzureRmResourceGroupDeploymentTemplate'.
VERBOSE: Exporting cmdlet 'Get-AzureRmResourceGroupDeploymentOperation'.
VERBOSE: Exporting cmdlet 'Get-AzureRmResourceLock'.
VERBOSE: Exporting cmdlet 'Invoke-AzureRmResourceAction'.
VERBOSE: Exporting cmdlet 'Move-AzureRmResource'.
VERBOSE: Exporting cmdlet 'New-AzureRmResourceLock'.
VERBOSE: Exporting cmdlet 'Get-AzureRmPolicyAssignment'.
VERBOSE: Exporting cmdlet 'Get-AzureRmPolicyDefinition'.
VERBOSE: Exporting cmdlet 'New-AzureRmPolicyAssignment'.
VERBOSE: Exporting cmdlet 'New-AzureRmPolicyDefinition'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmPolicyAssignment'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmPolicyDefinition'.
VERBOSE: Exporting cmdlet 'Set-AzureRmPolicyAssignment'.
VERBOSE: Exporting cmdlet 'Set-AzureRmPolicyDefinition'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmResource'.
VERBOSE: Exporting cmdlet 'Remove-AzureRmResourceLock'.
VERBOSE: Exporting cmdlet 'Set-AzureRmResource'.
VERBOSE: Exporting cmdlet 'New-AzureRmResource'.
VERBOSE: Exporting cmdlet 'Set-AzureRmResourceLock'.
VERBOSE: Exporting cmdlet 'Get-AzureRmResource'.
VERBOSE: Exporting alias 'Get-AzureRmResourceProviderAction'.
VERBOSE: Exporting alias 'Get-AzureRmADServicePrincipalCredential'.
VERBOSE: Exporting alias 'New-AzureRmADServicePrincipalCredential'.
VERBOSE: Exporting alias 'Remove-AzureRmADServicePrincipalCredential'.
VERBOSE: Exporting alias 'Set-AzureRmADApplication'.
VERBOSE: Exporting alias 'Set-AzureRmADServicePrincipal'.
VERBOSE: Exporting alias 'Set-AzureRmADUser'.
VERBOSE: Importing cmdlet 'Add-AzureRmADGroupMember'.
VERBOSE: Importing cmdlet 'Export-AzureRmResourceGroup'.
VERBOSE: Importing cmdlet 'Get-AzureRmADAppCredential'.
VERBOSE: Importing cmdlet 'Get-AzureRmADApplication'.
VERBOSE: Importing cmdlet 'Get-AzureRmADGroup'.
VERBOSE: Importing cmdlet 'Get-AzureRmADGroupMember'.
VERBOSE: Importing cmdlet 'Get-AzureRmADServicePrincipal'.
VERBOSE: Importing cmdlet 'Get-AzureRmADSpCredential'.
VERBOSE: Importing cmdlet 'Get-AzureRmADUser'.
VERBOSE: Importing cmdlet 'Get-AzureRmDeployment'.
VERBOSE: Importing cmdlet 'Get-AzureRmDeploymentOperation'.
VERBOSE: Importing cmdlet 'Get-AzureRmLocation'.
VERBOSE: Importing cmdlet 'Get-AzureRmManagedApplication'.
VERBOSE: Importing cmdlet 'Get-AzureRmManagedApplicationDefinition'.
VERBOSE: Importing cmdlet 'Get-AzureRmManagementGroup'.
VERBOSE: Importing cmdlet 'Get-AzureRmPolicyAssignment'.
VERBOSE: Importing cmdlet 'Get-AzureRmPolicyDefinition'.
VERBOSE: Importing cmdlet 'Get-AzureRmPolicySetDefinition'.
VERBOSE: Importing cmdlet 'Get-AzureRmProviderFeature'.
VERBOSE: Importing cmdlet 'Get-AzureRmProviderOperation'.
VERBOSE: Importing cmdlet 'Get-AzureRmResource'.
VERBOSE: Importing cmdlet 'Get-AzureRmResourceGroup'.
VERBOSE: Importing cmdlet 'Get-AzureRmResourceGroupDeployment'.
VERBOSE: Importing cmdlet 'Get-AzureRmResourceGroupDeploymentOperation'.
VERBOSE: Importing cmdlet 'Get-AzureRmResourceLock'.
VERBOSE: Importing cmdlet 'Get-AzureRmResourceProvider'.
VERBOSE: Importing cmdlet 'Get-AzureRmRoleAssignment'.
VERBOSE: Importing cmdlet 'Get-AzureRmRoleDefinition'.
VERBOSE: Importing cmdlet 'Invoke-AzureRmResourceAction'.
VERBOSE: Importing cmdlet 'Move-AzureRmResource'.
VERBOSE: Importing cmdlet 'New-AzureRmADAppCredential'.
VERBOSE: Importing cmdlet 'New-AzureRmADApplication'.
VERBOSE: Importing cmdlet 'New-AzureRmADGroup'.
VERBOSE: Importing cmdlet 'New-AzureRmADServicePrincipal'.
VERBOSE: Importing cmdlet 'New-AzureRmADSpCredential'.
VERBOSE: Importing cmdlet 'New-AzureRmADUser'.
VERBOSE: Importing cmdlet 'New-AzureRmDeployment'.
VERBOSE: Importing cmdlet 'New-AzureRmManagedApplication'.
VERBOSE: Importing cmdlet 'New-AzureRmManagedApplicationDefinition'.
VERBOSE: Importing cmdlet 'New-AzureRmManagementGroup'.
VERBOSE: Importing cmdlet 'New-AzureRmManagementGroupSubscription'.
VERBOSE: Importing cmdlet 'New-AzureRmPolicyAssignment'.
VERBOSE: Importing cmdlet 'New-AzureRmPolicyDefinition'.
VERBOSE: Importing cmdlet 'New-AzureRmPolicySetDefinition'.
VERBOSE: Importing cmdlet 'New-AzureRmResource'.
VERBOSE: Importing cmdlet 'New-AzureRmResourceGroup'.
VERBOSE: Importing cmdlet 'New-AzureRmResourceGroupDeployment'.
VERBOSE: Importing cmdlet 'New-AzureRmResourceLock'.
VERBOSE: Importing cmdlet 'New-AzureRmRoleAssignment'.
VERBOSE: Importing cmdlet 'New-AzureRmRoleDefinition'.
VERBOSE: Importing cmdlet 'Register-AzureRmProviderFeature'.
VERBOSE: Importing cmdlet 'Register-AzureRmResourceProvider'.
VERBOSE: Importing cmdlet 'Remove-AzureRmADAppCredential'.
VERBOSE: Importing cmdlet 'Remove-AzureRmADApplication'.
VERBOSE: Importing cmdlet 'Remove-AzureRmADGroup'.
VERBOSE: Importing cmdlet 'Remove-AzureRmADGroupMember'.
VERBOSE: Importing cmdlet 'Remove-AzureRmADServicePrincipal'.
VERBOSE: Importing cmdlet 'Remove-AzureRmADSpCredential'.
VERBOSE: Importing cmdlet 'Remove-AzureRmADUser'.
VERBOSE: Importing cmdlet 'Remove-AzureRmDeployment'.
VERBOSE: Importing cmdlet 'Remove-AzureRmManagedApplication'.
VERBOSE: Importing cmdlet 'Remove-AzureRmManagedApplicationDefinition'.
VERBOSE: Importing cmdlet 'Remove-AzureRmManagementGroup'.
VERBOSE: Importing cmdlet 'Remove-AzureRmManagementGroupSubscription'.
VERBOSE: Importing cmdlet 'Remove-AzureRmPolicyAssignment'.
VERBOSE: Importing cmdlet 'Remove-AzureRmPolicyDefinition'.
VERBOSE: Importing cmdlet 'Remove-AzureRmPolicySetDefinition'.
VERBOSE: Importing cmdlet 'Remove-AzureRmResource'.
VERBOSE: Importing cmdlet 'Remove-AzureRmResourceGroup'.
VERBOSE: Importing cmdlet 'Remove-AzureRmResourceGroupDeployment'.
VERBOSE: Importing cmdlet 'Remove-AzureRmResourceLock'.
VERBOSE: Importing cmdlet 'Remove-AzureRmRoleAssignment'.
VERBOSE: Importing cmdlet 'Remove-AzureRmRoleDefinition'.
VERBOSE: Importing cmdlet 'Save-AzureRmDeploymentTemplate'.
VERBOSE: Importing cmdlet 'Save-AzureRmResourceGroupDeploymentTemplate'.
VERBOSE: Importing cmdlet 'Set-AzureRmManagedApplication'.
VERBOSE: Importing cmdlet 'Set-AzureRmManagedApplicationDefinition'.
VERBOSE: Importing cmdlet 'Set-AzureRmPolicyAssignment'.
VERBOSE: Importing cmdlet 'Set-AzureRmPolicyDefinition'.
VERBOSE: Importing cmdlet 'Set-AzureRmPolicySetDefinition'.
VERBOSE: Importing cmdlet 'Set-AzureRmResource'.
VERBOSE: Importing cmdlet 'Set-AzureRmResourceGroup'.
VERBOSE: Importing cmdlet 'Set-AzureRmResourceLock'.
VERBOSE: Importing cmdlet 'Set-AzureRmRoleDefinition'.
VERBOSE: Importing cmdlet 'Stop-AzureRmDeployment'.
VERBOSE: Importing cmdlet 'Stop-AzureRmResourceGroupDeployment'.
VERBOSE: Importing cmdlet 'Test-AzureRmDeployment'.
VERBOSE: Importing cmdlet 'Test-AzureRmResourceGroupDeployment'.
VERBOSE: Importing cmdlet 'Unregister-AzureRmResourceProvider'.
VERBOSE: Importing cmdlet 'Update-AzureRmADApplication'.
VERBOSE: Importing cmdlet 'Update-AzureRmADServicePrincipal'.
VERBOSE: Importing cmdlet 'Update-AzureRmADUser'.
VERBOSE: Importing cmdlet 'Update-AzureRmManagementGroup'.
VERBOSE: Importing alias 'Get-AzureRmADServicePrincipalCredential'.
VERBOSE: Importing alias 'Get-AzureRmResourceProviderAction'.
VERBOSE: Importing alias 'New-AzureRmADServicePrincipalCredential'.
VERBOSE: Importing alias 'Remove-AzureRmADServicePrincipalCredential'.
VERBOSE: Importing alias 'Set-AzureRmADApplication'.
VERBOSE: Importing alias 'Set-AzureRmADServicePrincipal'.
VERBOSE: Importing alias 'Set-AzureRmADUser'.
PS C:\Users\sfibich\Source\Repos\powershell-awg> import-module azureRM -Verbose `` VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\azureRM\6.7.0\azureRM.psd1'. VERBOSE: Populating RepositorySourceLocation property for module azureRM. VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1'. Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:16 char:1
- Import-Module AzureRM.ApiManagement -RequiredVersion 6.1.3 -Global
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:20 char:1
- Import-Module AzureRM.Batch -RequiredVersion 4.1.3 -Global
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:24 char:1
- Import-Module AzureRM.Compute -RequiredVersion 5.5.0 -Global
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:28 char:1
- Import-Module AzureRM.DataFactories -RequiredVersion 5.0.3 -Global
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:36 char:1
- Import-Module AzureRM.HDInsight -RequiredVersion 4.1.6 -Global
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:39 char:1
- Import-Module AzureRM.KeyVault -RequiredVersion 5.1.1 -Global
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:50 char:1
- Import-Module AzureRM.RecoveryServices -RequiredVersion 4.1.6 -Global
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:51 char:1
- Import-Module AzureRM.RecoveryServices.Backup -RequiredVersion 4.4.0 ...
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:52 char:1
- Import-Module AzureRM.RecoveryServices.SiteRecovery -RequiredVersion ...
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:53 char:1
- Import-Module AzureRM.RedisCache -RequiredVersion 5.0.3 -Global
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:59 char:1
- Import-Module AzureRM.Sql -RequiredVersion 4.11.1 -Global
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Assembly with same name is already loaded At C:\Program Files\PowerShell\Modules\azureRM\6.7.0\AzureRM.psm1:60 char:1
- Import-Module AzureRM.Storage -RequiredVersion 5.0.2 -Global
-
- CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
- FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand ``
Upon closer examination I noticed you are using Netcore, I don't think it has the class,
System.Security.Cryptography.SHA256Cng
I also see there are previous issues related to this, https://github.com/Azure/azure-powershell/issues/5785 https://github.com/Azure/azure-powershell/issues/6629
I would recommend to try the AzureRM.Netcore or use PS 5.
#5785 is talking about login-AzureRM and is not using a App Registration/SPN account from what I can tell. I am using Connect-AzureRMAccount with a SPN so I don't know if they are speaking to the same issue or if Login-AzureRM is called by Connect-AzureRMAccount under the covers but they don't seem to be the same just related as you stated. It was closed because the person was not using an SPN and the feature was not supported, that is not exactly my case. I am using an SPN and still getting the error.
#6629 has a note stating that running install-module AzureRM.NetCore fixes the issue, I tried that and it did not fix the issue I get the same error. If that worked for them that is great I wish it worked for me.
Any thoughts?
Side note I run the exact same code on a RHEL box and it works with no issue.
I tried to reproduce your issue, but I cannot even get AzureRM.Profile to load in PowerShell 6. It gives me an error,
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.
When I run using AzureRM.Netcore it works for me. Also, unless there was a change since I last checked, AzureRM does not work on Linux, you must mean AzureRM.Netcore.
@sfibich Are you using AzureRM on powershell version 6.x?
@markcowl Yes I'm using Powershell version 6.1.0-preview.2 PSEdition Core for the Linux machine and PSVersion 6.0.4 and PSEdition Core for the Windows 2k12 server
@deathly809 I'm using the cmdlet connect-AzureRMAccount which looks to come from two different sources AzureRM.profile and AzureRM.Profile.Netcore on the windows box (I don't know how to tell which version I'm invoking when I call it) On the linux box it of course only has one source which AzureRM.Profile.Netcore
I'm going to try and see if I can force the windows box to call the connect-azureRMAccount from the AzureRM.Profile.Netcore source
Thoughts?
@sfibich I did a quick test using the Linux subsystem for Windows and I don't your exception.
However... I don't get anything at all.
Account :
SubscriptionName :
SubscriptionId :
TenantId :
Environment :
The version of NetCore I have installed is,
~$ apt list --installed | grep netcore
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
aspnetcore-store-2.0.0/xenial,now 2.0.0-1 amd64 [installed,automatic]
dotnet-sharedframework-microsoft.netcore.app-1.1.2/xenial,now 1.1.2-1 amd64 [installed,auto-removable]
What version do you have?
So I've been playing around and it looks like some issue with my IDE, I was using Visual Studio Code on the windows box. I have VSC configured to use PowerShell Shell pwsh.exe as the shell not the default shell but it seems to have an issue...digging into that but I think at this point is a VSC issue not a PWSH issue.
If I open the PowerShell Shell for 6.04 it works fine.
Thank you both for pointing me in the correct direction.
having the same issue here with pwsh. Any workaround/fix ?
@Bartmax I had to switch to regular PowerShell (the blue-background one) for this to work. I normally use Powershell 7 (the black open source) as default
Azure RM PowerShell is not compatible with Windows PowerShell 6 and I believe the latest PS 7 too.
https://docs.microsoft.com/en-us/powershell/azure/azurerm/install-azurerm-ps?view=azurermps-6.13.0#requirements
The module described in this document, AzureRM, uses .NET Framework. This makes it incompatible with PowerShell 6.0, which uses .NET Core. If you are using PowerShell 6.0, follow the installation instructions for macOS and Linux.
Is there any reason why you are recommending to use Powershell 7:https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.0.0 when one cannot even log in in Powershell 7?