Error running commands on Azure Subscription with PowerShell

Welcome Forums General PowerShell Q&A Error running commands on Azure Subscription with PowerShell

This topic contains 5 replies, has 3 voices, and was last updated by

 
Participant
1 month, 2 weeks ago.

  • Author
    Posts
  • #119088

    Participant
    Points: 31
    Rank: Member

    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?

  • #119098

    Participant
    Points: 112
    Helping Hand
    Rank: Participant

    Which version of the AzureRM module are you running?

    Get-Module AzureRM -ListAvailable

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

    Update-Module AzureRM

    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):

    choco install pwsh

    Then from PowerShell Core:

    Install-Module Az
    Connect-AzAccount -Subscription "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx"

    Just wondering if any of these options work for you.

  • #119101

    Keymaster
    Points: 17
    Team Member
    Rank: Member

    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.

  • #119109

    Participant
    Points: 31
    Rank: Member

    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)

  • #119163

    Participant
    Points: 31
    Rank: Member

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

    
    Get-AzureKeyVaultSecret
    
    

    instead of Get-AzureKeyVaultKey.

  • #119224

    Participant
    Points: 112
    Helping Hand
    Rank: Participant

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

You must be logged in to reply to this topic.