Reputation: 5165
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
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:
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:
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:
After installing AzureADPreview
module, I got the response successfully when I ran below command:
Get-AzureADMSPrivilegedRoleAssignment -ProviderId aadRoles -ResourceId <your_tenantID>
Response:
Upvotes: 2