Click here to Skip to main content
15,305,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am running a ps script (power shell 7) in Windows to programmatically extract a resource group as below:
PowerShell
Connect-AzureRmAccount -Subscription 'Demonstration Account'
$rg = Get-AzureRmResourceGroup -Name 'psdemo-rg' -Location 'centralus'

The first line sort of works because it launches the browser for me to login. However there is a
Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core,
     | Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

When the second line executes I get
Run Connect-AzureRmAccount to login.


So this makes me think that the login doesn't seem to stick around. Any idea what I'm doing wrong? Appreciate any suggestions

What I have tried:

I tried Connect-AzAccount to login but it's unrecognized...
Posted
Updated 4-Feb-21 0:28am

1 solution

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.
The AzureRM module does not work in PowerShell 6 or 7. The recommendation is to use the Az-PowerShell module instead.
Introducing the Azure Az PowerShell module | Microsoft Docs[^]

If you want to continue using AzureRM, you'll have to switch back to PowerShell 5.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900