The Remove-AzPolicyEnrollment cmdlet deletes a policy enrollment, given its name and the scope it was created in.
The scope of a policy enrollment is the part of its ID preceding '/providers/Microsoft.Authorization/policyEnrollments/{policyEnrollmentName}'.
Examples
Example 1: Remove policy enrollment by name and scope
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 removes the policy enrollment named PolicyEnrollment07 at the resource group scope.
The ResourceId property of $ResourceGroup identifies the resource group.
The first command gets a resource group named ResourceGroup11, and then stores that object in the $ResourceGroup variable.
The second command gets the policy enrollment at a resource group level, and then stores it in the $PolicyEnrollment variable.
The ResourceId property of $ResourceGroup identifies the resource group.
The final command removes the policy enrollment that the Id property of $PolicyEnrollment identifies, bypassing the confirmation prompt with the Force parameter.
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
The DefaultProfile parameter is not functional.
Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
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}')
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.
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.