Gallery › Guest Configuration › Azure built-in policies
[Preview]: Configure Windows Recovery Environment (WinRE) on Windows machines
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.0.0-preview Preview
Creates a Guest Configuration assignment to configure Enables the Windows Recovery Environment (WinRE) on Windows machines.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONConfigureWinREStatus_DINE.json · 131 lines
{
"properties": {
"displayName": "[Preview]: Configure Windows Recovery Environment (WinRE) on Windows machines",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Creates a Guest Configuration assignment to configure Enables the Windows Recovery Environment (WinRE) on Windows machines.",
"metadata": {
"version": "1.0.0-preview",
"category": "Guest Configuration",
"requiredProviders": [
"Microsoft.GuestConfiguration"
],
"preview": true,
"guestConfiguration": {
"name": "ConfigureWinREStatus",
"version": "1.*"
}
},
"version": "1.0.0-preview",
"parameters": {
"IncludeArcMachines": {
"type": "string",
"metadata": {
"displayName": "Include Arc connected servers",
"description": "By selecting this option, you agree to be charged monthly per Arc connected machine.",
"portalReview": "true"
},
"allowedValues": [
"true",
"false"
],
"defaultValue": "false"
},
"effect": {
"type": "string",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of this policy"
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.HybridCompute/machines"
},
{
"value": "[parameters('IncludeArcMachines')]",
"equals": "true"
},
{
"field": "Microsoft.HybridCompute/imageOffer",
"like": "windows*"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.GuestConfiguration/guestConfigurationAssignments",
"name": "ConfigureWinREStatus",
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/088ab73d-1256-47ae-bea9-9de8e7131f31"
],
"existenceCondition": {
"field": "Microsoft.GuestConfiguration/guestConfigurationAssignments/complianceStatus",
"equals": "Compliant"
},
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"vmName": {
"value": "[field('name')]"
},
"location": {
"value": "[field('location')]"
},
"configurationName": {
"value": "ConfigureWinREStatus"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"location": {
"type": "string"
},
"configurationName": {
"type": "string"
}
},
"resources": [
{
"apiVersion": "2018-11-20",
"type": "Microsoft.HybridCompute/machines/providers/guestConfigurationAssignments",
"name": "[concat(parameters('vmName'), '/Microsoft.GuestConfiguration/', parameters('configurationName'))]",
"location": "[parameters('location')]",
"properties": {
"guestConfiguration": {
"name": "[parameters('configurationName')]",
"version": "1.*",
"assignmentType": "ApplyAndMonitor"
}
}
}
]
}
}
}
}
}
},
"versions": [
"1.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/dd970030-1eb5-4d03-b72e-e2c59dcbb202",
"name": "dd970030-1eb5-4d03-b72e-e2c59dcbb202"
}Bylawdd970030-1eb5-4d03-b72e-e2c59dcbb202.bylaw.ps1 · 53 lines
# Converted from ConfigureWinREStatus_DINE.json by ConvertTo-Bylaw.
Policy 'dd970030-1eb5-4d03-b72e-e2c59dcbb202' {
Properties @{
DisplayName = '[Preview]: Configure Windows Recovery Environment (WinRE) on Windows machines'
Description = 'Creates a Guest Configuration assignment to configure Enables the Windows Recovery Environment (WinRE) on Windows machines.'
Version = '1.0.0-preview'
Category = 'Guest Configuration'
Preview = $true
PolicyVersion = '1.0.0-preview'
Mode = 'Indexed'
Metadata = [ordered]@{ requiredProviders = @('Microsoft.GuestConfiguration'); guestConfiguration = [ordered]@{ name = 'ConfigureWinREStatus'; version = '1.*' } }
}
Parameter IncludeArcMachines @{
Type = 'string'
AllowedValues = @('true', 'false')
Default = 'false'
DisplayName = 'Include Arc connected servers'
Description = 'By selecting this option, you agree to be charged monthly per Arc connected machine.'
JsonName = 'IncludeArcMachines'
Metadata = [ordered]@{ portalReview = 'true' }
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of this policy'
}
Resource 'Microsoft.HybridCompute/machines' {
When {
Param IncludeArcMachines | Must -Be 'true'
}
Require 'imageOffer is not like windows*' {
Field 'Microsoft.HybridCompute/imageOffer' | Must -Not -BeLike 'windows*' -IfPresent
}
}
DeployIfNotExists 'Microsoft.GuestConfiguration/guestConfigurationAssignments' -Role 'Guest Configuration Resource Contributor' -Name 'ConfigureWinREStatus' -Effect (Param Effect) {
Require 'complianceStatus is Compliant' {
Field complianceStatus | Must -Be 'Compliant'
}
Deployment -TemplateFile './templates/dd970030-1eb5-4d03-b72e-e2c59dcbb202.json' -Parameters ([ordered]@{
vmName = (Arm '[field(''name'')]')
location = (Arm '[field(''location'')]')
configurationName = 'ConfigureWinREStatus'
})
}
}Its deployment templates are written beside it:
templates/dd970030-1eb5-4d03-b72e-e2c59dcbb202.json
Source: built-in-policies/policyDefinitions/Guest Configuration/ConfigureWinREStatus_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw