Get-AzureADPolicy is not working under version Version 2.0.2.138

Benoit Tigeot 21 Reputation points
2021-11-30T10:31:30.483+00:00

With the existing version of AzureADPreview I am not able to run Get-AzureADPolicy.

I tried this solution: https://learn.microsoft.com/en-us/answers/questions/346121/get-azureadpolicy-is-not-working-under-version-ver.html

Without any success. I tried in a fresh powershell. Also I tried to uninstall AzureAD before to avoid conflict.

PS /home/benoit> Get-InstalledModule | grep ADP
2.0.2.138 AzureADPreview PSGallery Azure Active Directory V2 Preview Module. …
PS /home/benoit> Get-AzureADPolicy
Get-AzureADPolicy: The term 'Get-AzureADPolicy' 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.

Issue on cloudshell https://github.com/Azure/CloudShell/issues/111

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,653 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 105.5K Reputation points MVP
    2021-11-30T10:53:17+00:00

    Make sure the AzureADPreview module is loaded, you might have to remove the AzureAD one first.

    # 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.
    
    # Remove-Module AzureAD
    # Import-module AzureADPreview
    
    # Get-AzureADPolicy
    
    Id                                   DisplayName          Type                IsOrganizationDefaul
    --                                   -----------          ----                --------------------
    c9755042-7b11-4504-b9e6-6347d0beabf5 B2BManagementPolicy  B2BManagementPolicy True
    29155710-2987-424a-a58f-3dd445aa5c60 B2BManagementPolicy2 B2BManagementPolicy False
    

    Also, you CANNOT run this on Core/CloudShell, if that's what you're trying to do. The AzureAD module is only supported on Windows PowerShell.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Kalanithi K 1 Reputation point
    2022-02-28T22:49:12.847+00:00

    While importing module use "-RequiredVersion" parameter. Like this:

    "Connect-AzureAD;
    Import-Module AzureAdpreview -RequiredVersion 2.0.2.138"
    I hope this will enable you to run AzureAdpreview commands.
    178577-image.png

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.