Edit

Get-AzPolicyEnrollment

Gets policy enrollments.

Syntax

ListBySubscriptionId (Default)

Get-AzPolicyEnrollment
    [-SubscriptionId <String[]>]
    [-IncludeDescendent]
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

ListByResourceGroupName

Get-AzPolicyEnrollment
    -ResourceGroupName <String>
    [-SubscriptionId <String[]>]
    [-IncludeDescendent]
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

ListByScope

Get-AzPolicyEnrollment
    -Scope <String>
    [-IncludeDescendent]
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

GetByName

Get-AzPolicyEnrollment
    -Name <String>
    -Scope <String>
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

GetById

Get-AzPolicyEnrollment
    -Id <String>
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

ListByManagementGroupId

Get-AzPolicyEnrollment
    -ManagementGroupId <String>
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

Description

The Get-AzPolicyEnrollment cmdlet gets a collection of policy enrollments or a specific policy enrollment identified by name or ID.

Examples

Example 1: Get all policy enrollments

Get-AzPolicyEnrollment

This command gets all the policy enrollments in the current subscription. If you need to list all enrollments related to the given scope, including those from ancestor scopes and those from descendant scopes, pass the -IncludeDescendent parameter.

Example 2: Get a specific policy enrollment by name and scope

$ResourceGroup = Get-AzResourceGroup -Name 'ResourceGroup11'
Get-AzPolicyEnrollment -Name 'PolicyEnrollment07' -Scope $ResourceGroup.ResourceId

The first command gets a resource group named ResourceGroup11 by using the Get-AzResourceGroup cmdlet and stores it in the $ResourceGroup variable. The second command gets the policy enrollment named PolicyEnrollment07 for the scope that the ResourceId property of $ResourceGroup identifies.

Example 3: Get all policy enrollments at management group scope

$ManagementGroup = Get-AzManagementGroup -GroupName 'AManagementGroup'
Get-AzPolicyEnrollment -ManagementGroupId $ManagementGroup.Name

The first command gets a management group named AManagementGroup by using the Get-AzManagementGroup cmdlet and stores it in the $ManagementGroup variable. The second command gets all policy enrollments at the management group scope identified by the Name property of $ManagementGroup.

Parameters

-DefaultProfile

The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.

Parameter properties

Type:PSObject
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzureRMContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Id

The fully qualified resource Id of the policy enrollment.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:ResourceId

Parameter sets

GetById
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-IncludeDescendent

Causes the list of returned policy enrollments to include all policy enrollments related to the given scope, including those from ancestor scopes and those from descendent scopes. If not provided, only policy enrollments at and above the given scope are included.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ListBySubscriptionId
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ListByResourceGroupName
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ListByScope
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ManagementGroupId

The management group ID.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ListByManagementGroupId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Name

The name of the policy enrollment.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:PolicyEnrollmentName

Parameter sets

GetByName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ResourceGroupName

The name of the resource group. The name is case insensitive.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ListByResourceGroupName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Scope

The scope of the policy enrollment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'), or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}')

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ListByScope
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
GetByName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-SubscriptionId

The ID of the target subscription.

Parameter properties

Type:

String[]

Default value:(Get-AzContext).Subscription.Id
Supports wildcards:False
DontShow:False

Parameter sets

ListBySubscriptionId
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ListByResourceGroupName
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

SwitchParameter

String

String

Outputs

IPolicyEnrollment