New-​Azure​Rm​Policy​Definition

Creates a policy definition.

Syntax

New-AzureRmPolicyDefinition
   -Name <String>
   [-DisplayName <String>]
   [-Description <String>]
   -Policy <String>
   [-ApiVersion <String>]
   [-Pre]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-Parameter <String>]
   [<CommonParameters>]

Description

The New-AzureRmPolicyDefinition cmdlet creates a policy definition that includes a policy rule in JavaScript Object Notation (JSON) format.

Examples

Example 1: Create a policy definition by using a policy file

PS C:\>New-AzureRmPolicyDefinition -Name "VMPolicyDefinition" -Policy C:\VMPolicy.json

This command creates a policy definition named VMPolicyDefinition that contains the policy rule specified in C:\VMPolicy.json.

Example 2: Create a policy definition inline

PS C:\>New-AzureRmPolicyDefinition -Name "VMPolicyDefinition" -DisplayName "Virtual Machine policy definition" -Policy "{""if"":{""source"":""action"",""equals"":""Microsoft.Compute/virtualMachines/write""},""then"":{""effect"":""deny""}}"

This command creates a policy definition named VMPolicyDefinition. The command specifies the policy as a string in valid JSON format.

Required Parameters

-Name

Specifies a name for the policy definition.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Policy

Specifies a policy rule for the policy definition. You can specify the path of a .json file or a string that contains the policy in JSON format.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-ApiVersion

Specifies the version of the resource provider API to use. If you do not specify a version, this cmdlet uses the latest available version.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Description

Specifies a description for the policy definition.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-DisplayName

Specifies a display name for the policy definition.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-InformationAction

Specifies how this cmdlet responds to an information event.The acceptable values for this parameter are:- Continue

  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend
Type:ActionPreference
Aliases:infa
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Parameter

The parameters declaration for policy definition. This can either be a path to a file name containing the parameters declaration, or the parameters declaration as string.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Pre

Indicates that this cmdlet considers pre-release API versions when it automatically determines which version to use.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False