Gallery › Compute › Azure built-in policies
Microsoft IaaSAntimalware extension should be deployed on Windows servers
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.1.0
This policy audits any Windows server VM without Microsoft IaaSAntimalware extension deployed.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONWindowsServers_AntiMalware_AINE.json · 94 lines
{
"properties": {
"displayName": "Microsoft IaaSAntimalware extension should be deployed on Windows servers",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "This policy audits any Windows server VM without Microsoft IaaSAntimalware extension deployed.",
"metadata": {
"version": "1.1.0",
"category": "Compute"
},
"version": "1.1.0",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "AuditIfNotExists",
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachines"
},
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "MicrosoftWindowsServer"
},
{
"field": "Microsoft.Compute/imageOffer",
"equals": "WindowsServer"
},
{
"field": "Microsoft.Compute/imageSKU",
"in": [
"2008-R2-SP1",
"2008-R2-SP1-smalldisk",
"2012-Datacenter",
"2012-Datacenter-smalldisk",
"2012-R2-Datacenter",
"2012-R2-Datacenter-smalldisk",
"2016-Datacenter",
"2016-Datacenter-Server-Core",
"2016-Datacenter-Server-Core-smalldisk",
"2016-Datacenter-smalldisk",
"2016-Datacenter-with-Containers",
"2016-Datacenter-with-RDSH",
"2019-Datacenter",
"2019-Datacenter-Core",
"2019-Datacenter-Core-smalldisk",
"2019-Datacenter-Core-with-Containers",
"2019-Datacenter-Core-with-Containers-smalldisk",
"2019-datacenter-gensecond",
"2019-Datacenter-smalldisk",
"2019-Datacenter-with-Containers",
"2019-Datacenter-with-Containers-smalldisk"
]
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Compute/virtualMachines/extensions",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Compute/virtualMachines/extensions/type",
"equals": "IaaSAntimalware"
},
{
"field": "Microsoft.Compute/virtualMachines/extensions/publisher",
"equals": "Microsoft.Azure.Security"
}
]
}
}
}
},
"versions": [
"1.1.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/9b597639-28e4-48eb-b506-56b05d366257",
"name": "9b597639-28e4-48eb-b506-56b05d366257"
}Bylaw9b597639-28e4-48eb-b506-56b05d366257.bylaw.ps1 · 39 lines
# Converted from WindowsServers_AntiMalware_AINE.json by ConvertTo-Bylaw.
Policy '9b597639-28e4-48eb-b506-56b05d366257' {
Properties @{
DisplayName = 'Microsoft IaaSAntimalware extension should be deployed on Windows servers'
Description = 'This policy audits any Windows server VM without Microsoft IaaSAntimalware extension deployed.'
Version = '1.1.0'
Category = 'Compute'
PolicyVersion = '1.1.0'
Mode = 'Indexed'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Compute/virtualMachines' {
When {
Field 'Microsoft.Compute/imagePublisher' | Must -Be 'MicrosoftWindowsServer'
Field 'Microsoft.Compute/imageOffer' | Must -Be 'WindowsServer'
}
Require 'imageSKU is not one of 21 values' {
Field 'Microsoft.Compute/imageSKU' | Must -Not -BeIn @('2008-R2-SP1', '2008-R2-SP1-smalldisk', '2012-Datacenter', '2012-Datacenter-smalldisk', '2012-R2-Datacenter', '2012-R2-Datacenter-smalldisk', '2016-Datacenter', '2016-Datacenter-Server-Core', '2016-Datacenter-Server-Core-smalldisk', '2016-Datacenter-smalldisk', '2016-Datacenter-with-Containers', '2016-Datacenter-with-RDSH', '2019-Datacenter', '2019-Datacenter-Core', '2019-Datacenter-Core-smalldisk', '2019-Datacenter-Core-with-Containers', '2019-Datacenter-Core-with-Containers-smalldisk', '2019-datacenter-gensecond', '2019-Datacenter-smalldisk', '2019-Datacenter-with-Containers', '2019-Datacenter-with-Containers-smalldisk') -IfPresent
}
}
AuditIfNotExists 'Microsoft.Compute/virtualMachines/extensions' -Effect (Param Effect) {
Require 'type is IaaSAntimalware and publisher is Microsoft.Azure.Security' {
Field 'Microsoft.Compute/virtualMachines/extensions/type' | Must -Be 'IaaSAntimalware'
Field publisher | Must -Be 'Microsoft.Azure.Security'
}
}
}Source: built-in-policies/policyDefinitions/Compute/WindowsServers_AntiMalware_AINE.json in Azure/azure-policy, under the MIT licence.
Bylaw