PowerShell Azure commands not recognized in PowerShell 7

Rafael Colorado 1 Reputation point
2021-11-25T15:48:35.247+00:00

I downloaded PowerShell 7(x64) to my LapTop using Windows11 and when I use basic Azure commands like Get-Account (Get-AzAccount) or Get-Subscription (Get-AzSubscription)and I get this:
"Get-AzureContext or Get-AzContext: The term 'Get-AzureContext' is not recognized as a name of a cmdlet, function, script file, or executable program."
What am I doing wrong? thanks

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,381 questions
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Rich Matheisen 45,091 Reputation points
    2021-11-25T16:20:16.337+00:00

    Shouldn't you be using Get-AZContext instead?

    install-az-ps

    If you have AzureRM installed, check this, too: install-az-ps

    0 comments No comments

  2. Rafael Colorado 1 Reputation point
    2021-11-25T17:03:33.06+00:00

    Thanks my mistake I was using Get-AzContext and got the same error:
    PS C:\Users\rcolorado> Get-AzContext
    Get-AzContext : The term 'Get-AzContext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

    0 comments No comments

  3. Rich Matheisen 45,091 Reputation points
    2021-11-25T20:03:00.907+00:00

    Have you installed the module "Az"? You should be able to find it on your machine using Get-Module:

    Get-Module -Name Az -All
    
    0 comments No comments

  4. Rafael Colorado 1 Reputation point
    2021-11-26T19:16:07.337+00:00

    Thanks, Rich but after using "Get-Module -Name Az -All", I keep getting the same error (see below). Any other advice?
    PS C:\Users\rcolorado> Get-Module -Name Az -All
    PS C:\Users\rcolorado> Connect-AzAccount
    Connect-AzAccount : The term 'Connect-AzAccount' is not recognized as the name of a cmdlet,
    function, script file, or operable program. Check the spelling of the name, or if a path was
    included, verify that the path is correct and try again.


  5. Price, Rebekah 0 Reputation points
    2023-03-24T17:47:18.4933333+00:00

    I was experiencing the same as Rafael, and thought I'd post my resolution here.

    >Install-Module Az -All

    (This part is very likely overkill, but it worked and I don't have to worry about anymore missing modules.)

    My next hurdle was a warning, followed by an error. The warning was: "WARNING: Both Az and AzureRM modules were detected on this machine." The solution is to uninstall AzureRM, the older version.

    >Uninstall-AzureRm

    From there, I was forced to login again, then received the results I expected.

    >Connect-AzAccount

    My test:

    (Enter YOUR TenantId, resourceGroup and webAppName.)

    # Your tenant ID (in the Azure portal, under Azure Active Directory > Overview).

    $TenantID="b000ce86-bd72-4dab-94a7-a513b4c3052e"

    $resourceGroup = "MyShinyResourceGroup"

    $webAppName="MyShnazzyApp"

    "$TenantID"

    "$resourceGroup"

    "$webAppName"

    # Get the ID of the managed identity for the web app.

    $spID = (Get-AzWebApp -ResourceGroupName $resourceGroup -Name $webAppName).identity.principalid

    "$spID"

    Note: I still don't receive any output from any of the commands meant to output module names, but they aren't throwing missing module errors, so I'm happy for now.

    0 comments No comments