Error running commands on Azure Subscription with PowerShell

This is my initial code

Connect-AzureRmAccount -Subscription "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx"

I am then prompted for credentials and authenticate to a subscription i have “reader” permissions for.

The next command I run is

Get-AzureRmContext

and the correct info appears (name / account / sub name), however subsequent commands such as to azure resources in that subscription do not return any values though they do return values in the azure cloudshell interface.

Any thoughts?

Which version of the AzureRM module are you running?

[pre]Get-Module AzureRM -ListAvailable[/pre]

Make sure you get the latest https://www.powershellgallery.com/packages/AzureRM

[pre]Update-Module AzureRM[/pre]

Azure Cloud Shell runs PowerShell Core. You could try and install PowerShell Core and the Az module, which is in Preview, but will be replacing AzureRM in the future.

Get PowerShell Core (for instance with Chocolatey):

[pre]choco install pwsh[/pre]

Then from PowerShell Core:

[pre]Install-Module Az
Connect-AzAccount -Subscription “xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx”[/pre]

Just wondering if any of these options work for you.

What version of the AzureRM module are you running out of curiousity on your local machine? Can you try to run the same commands on a virtual machine outside of your environment for grins? Also, can you list all of the permissions that you have for that environment? I’ll set up an account with similar perms in mine and see if I can dupe the issue.

I ran Get-Module AzureRM -List available and got 2 versions available:

6.7.0

5.1.1

Note: I’m running windows 10, so using WindowsPowerShell and I have “reader” across the board on the subscription and to all resources (VM’s, keyvault, etc)

Hi guys, it was a dumb error on my part. I should have been running

Get-AzureKeyVaultSecret

instead of Get-AzureKeyVaultKey.

Good to hear you have your issue resolved. Thanks for getting back to us!