The term 'Get-AzADServicePrincipal' is not recognized as the name of a cmdlet, function

Viewed 3396

I'm trying to set access policy in azure key vault by following below msdn docs

https://docs.microsoft.com/en-us/azure/key-vault/general/assign-access-policy-powershell

I followed the steps like installed AzureAd in the powershell and connected with azure. But when I run the next steps I'm facing the issue like

Get-AzADServicePrincipal : The term 'Get-AzADServicePrincipal' 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-AzADServicePrincipal -SearchString PI
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-AzADServicePrincipal:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Not sure what are the steps I'm missing.

2 Answers

Try running the install again with -AllowClobber.

Install-Module -Name Az -AllowClobber

The command Get-AzADServicePrincipal is in the module Az.Resources. It does not a command of AzureAD module. For more details, please refer to here.

Regarding the issue, please refer to the following steps

  1. Assign your account to Azure AD role

  2. Script

Connect-AzAccount
Get-AzADServicePrincipal

enter image description here

Related