Search code examples
azurepowershell

Azure Powershell: Get-MgUser not recognized


I ran Import-Module Microsoft.Graph.Applications and Connect-MgGraph with many scopes. I am now trying to run the command New-MgUser, but I receive this error:

Get-MgUser: The term 'Get-MgUser' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Does anyone have suggestions on how to fix this so I can run New-MgUser and Get-MgUser?


Solution

  • You are missing the module that has those 2 cmdlets:

    Install-Module Microsoft.Graph.Users
    

    Also, Connect-MgGraph is from Microsoft.Graph.Authentication not from Microsoft.Graph.Applications.

    You can always use Find-Command to verify that:

    PS ..\pwsh> Find-Command Get-MgUser, Connect-MgGraph
    
    Name               Version    ModuleName                        Repository
    ----               -------    ----------                        ----------
    Get-MgUser         2.25.0     Microsoft.Graph.Users             PSGallery 
    Connect-MgGraph    2.25.0     Microsoft.Graph.Authentication    PSGallery