Edit

Update-AzPolicyEnrollment

This operation updates a policy enrollment with the newly provided properties.

Syntax

UpdateByNameAndScope (Default)

Update-AzPolicyEnrollment
    -Name <String>
    -Scope <String>
    [-Description <String>]
    [-DisplayName <String>]
    [-AssignmentScopeValidation <String>]
    [-ResourceSelector <IResourceSelector[]>]
    [-PolicyDefinitionReferenceId <String[]>]
    [-Metadata <String>]
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

UpdateByInputObject

Update-AzPolicyEnrollment
    -InputObject <IPolicyEnrollment>
    [-Description <String>]
    [-DisplayName <String>]
    [-AssignmentScopeValidation <String>]
    [-ResourceSelector <IResourceSelector[]>]
    [-PolicyDefinitionReferenceId <String[]>]
    [-Metadata <String>]
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

UpdateById

Update-AzPolicyEnrollment
    -Id <String>
    [-Description <String>]
    [-DisplayName <String>]
    [-AssignmentScopeValidation <String>]
    [-ResourceSelector <IResourceSelector[]>]
    [-PolicyDefinitionReferenceId <String[]>]
    [-Metadata <String>]
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

Description

The Update-AzPolicyEnrollment cmdlet updates a policy enrollment with the newly provided properties.

Any properties not provided will be preserved from the existing enrollment.

Examples

Example 1: Update the display name

$ResourceGroup = Get-AzResourceGroup -Name 'ResourceGroup11'
$PolicyEnrollment = Get-AzPolicyEnrollment -Name 'PolicyEnrollment07' -Scope $ResourceGroup.ResourceId
Update-AzPolicyEnrollment -Id $PolicyEnrollment.Id -DisplayName 'Enrollment for VM location policy'

The first command gets a resource group named ResourceGroup11 by using the Get-AzResourceGroup cmdlet. The command stores that object in the $ResourceGroup variable. The second command gets the policy enrollment named PolicyEnrollment07 by using the Get-AzPolicyEnrollment cmdlet. The command stores that object in the $PolicyEnrollment variable. The final command updates the display name on the policy enrollment identified by the Id property of $PolicyEnrollment.

Example 2: Update via pipeline

$PolicyEnrollment = Get-AzPolicyEnrollment -Name 'PolicyEnrollment07' -Scope "/subscriptions/$((Get-AzContext).Subscription.Id)"
$PolicyEnrollment.DisplayName = 'Updated VM Enrollment'
$PolicyEnrollment | Update-AzPolicyEnrollment

The first command gets the policy enrollment named PolicyEnrollment07 by using the Get-AzPolicyEnrollment cmdlet and stores it in the $PolicyEnrollment variable. The second command sets a new display name on the $PolicyEnrollment object. The final command pipes the modified object to Update-AzPolicyEnrollment to persist the change.

Example 3: Update the resource selector

$ResourceGroup = Get-AzResourceGroup -Name 'ResourceGroup11'
$ResourceSelector = @{Name = "MyLocationSelector"; Selector = @(@{Kind = "resourceLocation"; NotIn = @("eastus", "eastus2")})}
Update-AzPolicyEnrollment -Name 'VirtualMachinePolicyEnrollment' -Scope $ResourceGroup.ResourceId -ResourceSelector $ResourceSelector

The first command gets a resource group named ResourceGroup11 by using the Get-AzResourceGroup cmdlet. The second command creates a resource selector object that limits the enrollment to resources in locations other than East US or East US 2 and stores it in the $ResourceSelector variable. The final command updates the policy enrollment named VirtualMachinePolicyEnrollment with the resource selector specified by $ResourceSelector.

Parameters

-AssignmentScopeValidation

The option whether to validate the enrollment is at or under the assignment scope.

Parameter properties

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

Parameter sets

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

-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

-Description

The description of the policy enrollment.

Parameter properties

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

Parameter sets

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

-DisplayName

The display name of the policy enrollment.

Parameter properties

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

Parameter sets

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

-Id

The ID of the policy enrollment to update. Use the format '{scope}/providers/Microsoft.Authorization/policyEnrollments/{policyEnrollmentName}'.

Parameter properties

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

Parameter sets

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

-InputObject

The Policy Enrollment object to update.

Parameter properties

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

Parameter sets

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

-Metadata

The policy enrollment metadata. Metadata is an open ended object and is typically a collection of key value pairs.

Parameter properties

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

Parameter sets

(All)
Position:Named
Mandatory:False
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

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

-PolicyDefinitionReferenceId

When the associated policy assignment is for a policy set (initiative), this can be used to specify the policy definition reference IDs for policy definitions in the policy set that should be enrolled to. These IDs correspond to a subset of policyDefinitions[*].policyDefinitionReferenceId in the policy set definition. When specified and not empty, only the referenced policy definitions will be enrolled to. Otherwise, the entire policy set is enrolled to.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

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

-ResourceSelector

The resource selector list to filter policies by resource properties.

Parameter properties

Type:

IResourceSelector[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
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

UpdateByNameAndScope
Position:Named
Mandatory:True
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

IPolicyEnrollment

IResourceSelector

String

String

Outputs

IPolicyEnrollment