Jim Macaulay
Jim Macaulay

Reputation: 5165

Get-AzureADMSPrivilegedRoleAssignment : The term 'Get-AzureADMSPrivilegedRoleAssignment' is not recognized

Unable to execute Get-AzureADMSPrivilegedRoleAssignment in powershell its giving me an error as Get-AzureADMSPrivilegedRoleAssignment : The term 'Get-AzureADMSPrivilegedRoleAssignment' is not recognized

I tried installing AzureADPreview module, it says the module already present, but still am getting this error.

Get-AzureADMSPrivilegedRoleAssignment : The term 'Get-AzureADMSPrivilegedRoleAssignment' 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.
At line:1 char:1
+ Get-AzureADMSPrivilegedRoleAssignment
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-AzureADMSPrivilegedRoleAssignment:String) [], CommandNotFoundExcept
   ion
    + FullyQualifiedErrorId : CommandNotFoundException

Any suggestion will be helpful.

Upvotes: 2

Views: 7008

Answers (1)

Sridevi
Sridevi

Reputation: 22597

Get-AzureADMSPrivilegedRoleAssignment : The term 'Get-AzureADMSPrivilegedRoleAssignment' is not recognized as the name of a cmdlet, function, script file, or operable program.

This error usually occurs when you don't have AzureADPreview module installed while running that command.

I tried to reproduce the same in my environment and got the same error as below:

Connect-AzureAD -TenantId <your_tenantID>
Get-Module -Name *AzureAD*
Get-AzureADMSPrivilegedRoleAssignment -ProviderId aadRoles -ResourceId <your_tenantID>

Response:

enter image description here

To resolve the error, you need to install AzureADPreview module.

If you try to install that module without removing AzureAD module, you will get error as below:

 Install-Module -Name AzureADPreview

Response: enter image description here

To resolve this, close the existing session and open new PowerShell window by running as Administrator.

Make sure to uninstall AzureAD module and install AzureADPreview module like below:

Uninstall-Module -Name AzureAD
Install-Module -Name AzureADPreview
Import-Module AzureAD
Connect-AzureAD -TenantId <your_tenantID>
Get-Module *AzureAD*

Response: enter image description here

After installing AzureADPreview module, I got the response successfully when I ran below command:

Get-AzureADMSPrivilegedRoleAssignment -ProviderId aadRoles -ResourceId <your_tenantID>

Response:

enter image description here

Upvotes: 2

Related Questions