Get-EntraPolicy
Gets a policy.
Syntax
Get-EntraPolicy
[-Top <Int32>]
[-All]
[<CommonParameters>]
Get-EntraPolicy
-Id <String>
[-All]
[<CommonParameters>]
Description
The Get-EntraPolicy
cmdlet gets a policy in Microsoft Entra ID. Specify Id
parameter to get a policy.
Examples
Example 1: Get all policies
Connect-Entra -Scopes 'Policy.Read.All'
Get-EntraPolicy
Definition DeletedDateTime Description DisplayName Id
---------- --------------- ----------- ----------- --
{{"activityBasedTimeoutPolicies":{"AlternateLoginIDLookup":true, "IncludedUserIds":["UserID"]}}} Activepolicy bbbbbbbb-1111-2222-3333-cccccccccccc
{{"HomeRealmDiscoveryPolicy":{"AlternateLoginIDLookup":true, "IncludedUserIds":["UserID"]}}} PolicyDemo aaaaaaaa-1111-1111-1111-000000000000
This example shows how to return all policies.
Example 2: Get policy using Display Name
Connect-Entra -Scopes 'Policy.Read.All'
Get-EntraPolicy | Where-Object {$_.DisplayName -eq 'Microsoft User Default Recommended Policy'}
DeletedDateTime Description DisplayName Id
--------------- ----------- ----------- --
Permissions consentable based on Microsoft's current recommendations. Microsoft User Default Recommended Policy microsoft-user-default-recommended
This example shows how to get a specific policy using Display Name.
Example 3: Get a policy with specific ID
Connect-Entra -Scopes 'Policy.Read.All'
Get-EntraPolicy -Id 'bbbbbbbb-1111-2222-3333-cccccccccccc'
Id Description DisplayName Feature IsAppliedToOrganization IsEnabled
-- ----------- ----------- ------- ----------------------- ---------
bbbbbbbb-1111-2222-3333-cccccccccccc passwordHashSync rollout policy passwordHashSync rollout policy passwordHashSync False True
This example demonstrated how to receive policy with specific ID.
Id
parameter specifies the unique policy ID, which you want to receive. In this example,bbbbbbbb-1111-2222-3333-cccccccccccc
represents the ID of the policy.
Example 4: Get all policies
Connect-Entra -Scopes 'Policy.Read.All'
Get-EntraPolicy -All
Definition DeletedDateTime Description DisplayName Id
---------- --------------- ----------- ----------- --
{{"activityBasedTimeoutPolicies":{"AlternateLoginIDLookup":true, "IncludedUserIds":["UserID"]}}} Activepolicy bbbbbbbb-1111-2222-3333-cccccccccccc
{{"HomeRealmDiscoveryPolicy":{"AlternateLoginIDLookup":true, "IncludedUserIds":["UserID"]}}} PolicyDemo aaaaaaaa-1111-1111-1111-000000000000
This example demonstrates how to retrieve all policies in Microsoft Entra ID.
Example 5: Get the top one policy
Connect-Entra -Scopes 'Policy.Read.All'
Get-EntraPolicy -Top 1
Id Description DisplayName Feature IsAppliedToOrganization IsEnabled
-- ----------- ----------- ------- ----------------------- ---------
bbbbbbbb-1111-2222-3333-cccccccccccc passwordHashSync rollout policy passwordHashSync rollout policy passwordHashSync False True
This example demonstrates how to retrieve top one policies in Microsoft Entra ID.
Parameters
-All
List all policies.
Type: | System.Management.Automation.SwitchParameter |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Id
The Id of the policy you want to retrieve.
Type: | System.String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Top
Specifies the maximum number of records to return.
Type: | System.Int32 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |