Skip to content

PolicyDefinition

SYNOPSIS

A policy the initiative includes: a policy from this build by name, or any definition by ID.

SYNTAX

PolicyDefinition [[-Name] <Object>] [[-Options] <Object>] [-Id <String>] [-ReferenceId <String>] [-Parameters <IDictionary>] [-Version <String>] [-Group <String[]>] [<CommonParameters>]

DESCRIPTION

One-line form: PolicyDefinition 'policy-name' -Version '1..' -Group AC-2 Hashtable form: PolicyDefinition 'policy-name' @{ Version = '1..'; Group = 'AC-2' } PolicyDefinition @{ Id = ''; ReferenceId = 'Name'; Version = '1..' }

The hashtable form takes the same options as keys, one per line, for a member too long for one line (ADR-0033). A member by Id has no name, so its options all go in the hashtable.

USED IN

Initiative

EXAMPLES

Example 1

PolicyDefinition 'general-require-tag' -Parameters @{ tagName = Param RequiredTag }

Example 2

PolicyDefinition -Id cd3aa116-8754-49c9-a813-ad46512ece54 -ReferenceId 'InheritCostCenter' -Parameters @{ tagName = 'CostCenter' }

Example 3

PolicyDefinition @{
    Id          = 'cd3aa116-8754-49c9-a813-ad46512ece54'
    ReferenceId = 'InheritCostCenter'
    Version     = '1.*.*'
    Group       = 'Tags', 'Cost Management'
    Parameters  = @{ tagName = 'CostCenter' }
}

PARAMETERS

-Name

The name of a policy in this build, or a hashtable with the keys Name, Id, ReferenceId, Parameters, Version and Group.

Type: Object
Required: false
Position: 1
Accept pipeline input: false

-Options

The options as a hashtable, after the name: the same keys as above, without Name.

Type: Object
Required: false
Position: 2
Accept pipeline input: false

-Id

A definition ID, for a built-in policy or one outside this build. A GUID on its own is a built-in policy: /providers/Microsoft.Authorization/policyDefinitions/.

Type: String
Required: false
Position: named
Accept pipeline input: false

-ReferenceId

The member's policyDefinitionReferenceId. Defaults to the policy name; required with -Id.

Type: String
Required: false
Position: named
Accept pipeline input: false

-Parameters

Values for the member's parameters: a literal, Param, Arm or ResourceGroupTag.

Type: IDictionary
Required: false
Position: named
Accept pipeline input: false

-Version

The definition version to use, e.g. '1..', or '1.2.*' to pin the minor version. The patch is always *: Azure always takes the newest patch, and rejects a fixed one (BYL1053).

Type: String
Required: false
Position: named
Accept pipeline input: false

-Group

The definition groups the member belongs to.

Type: String[]
Required: false
Position: named
Accept pipeline input: false