Share via


Azure AD Troubleshooting: PowerShellPreview command-lets

Issue

Working with Azure AD Policy which can be managed via Azure AD Preview PowerShell Command Let. installed the module, as steps described here Azure AD Preview but still not able to run Get-AzureADPolicy command-let

Troubleshooting

PS <C:\Program Files\WindowsPowerShell\Modules\AzureADPreview\2.0.1.11>> Get-AzureADPolicy

Get-AzureADPolicy : The term 'Get-AzureADPolicy' 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-AzureADPolicy

+ ~~~~~~~~~~~~~~~~~

+ CategoryInfo : ObjectNotFound: (Get-AzureADPolicy:String) [], CommandNotFoundException

+ FullyQualifiedErrorId : CommandNotFoundException

However, PowerShell is auto completing my command-let, so looks like, it was resolving the command.

Explicitly, Import-Module AzureADPreview did not help either. 

Root cause: Two modules installed AzureAD and AzureADPreview, which is causing this problem. 

Solution

Open a fresh elevated PowerShell. You need to load the AzureADPreview module on a new PowerShellModule 

Run following command

Import-Module .\AzureADPreview.psd1

Run the below command 

Connect-AzureAD

 Provide Global Admin username/password 

Now, you should be able to run the Get-AzureADPolicy Command-let successfully.