Bylaw

Gallery › Guest Configuration › Azure built-in policies

[Deprecated]: Windows machines should schedule Windows Defender to perform a scheduled scan every day

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.3.0-deprecated Deprecated

This policy is deprecated because Microsoft 365 App Compliance Program no longer checks schedule frequency on Windows machines. Learn more details about the latest M365 APP Compliance requirements at aka.ms/acat-cert2-seg-ops. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONACAT_WindowsDefenderScanScheduleDaily_AINE.json · 271 lines
{
  "properties": {
    "displayName": "[Deprecated]: Windows machines should schedule Windows Defender to perform a scheduled scan every day",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy is deprecated because Microsoft 365 App Compliance Program no longer checks schedule frequency on Windows machines. Learn more details about the latest M365 APP Compliance requirements at aka.ms/acat-cert2-seg-ops. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.",
    "metadata": {
      "category": "Guest Configuration",
      "version": "1.3.0-deprecated",
      "deprecated": true,
      "requiredProviders": [
        "Microsoft.GuestConfiguration"
      ],
      "guestConfiguration": {
        "name": "WindowsDefenderScanScheduleDaily",
        "version": "1.11.*"
      }
    },
    "version": "1.3.0",
    "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."
        },
        "allowedValues": [
          "True",
          "False"
        ],
        "defaultValue": "False"
      },
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of this policy"
        },
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "defaultValue": "Disabled"
      }
    },
    "policyRule": {
      "if": {
        "anyOf": [
          {
            "allOf": [
              {
                "field": "type",
                "equals": "Microsoft.Compute/virtualMachines"
              },
              {
                "anyOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "in": [
                      "esri",
                      "incredibuild",
                      "MicrosoftDynamicsAX",
                      "MicrosoftSharepoint",
                      "MicrosoftVisualStudio",
                      "MicrosoftWindowsDesktop",
                      "MicrosoftWindowsServerHPCPack"
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "field": "Microsoft.Compute/imagePublisher",
                        "equals": "MicrosoftWindowsServer"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "notLike": "2008*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "notIn": [
                          "2012-Datacenter",
                          "2012-Datacenter-smalldisk",
                          "2012-R2-Datacenter",
                          "2012-R2-Datacenter-smalldisk",
                          "2016-Datacenter-Server-Core",
                          "2016-Datacenter-Server-Core-smalldisk",
                          "2016-Datacenter-smalldisk",
                          "2016-Datacenter-with-Containers",
                          "2016-Datacenter-with-RDSH",
                          "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"
                        ]
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "field": "Microsoft.Compute/imagePublisher",
                        "equals": "MicrosoftSQLServer"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "notLike": "SQL2008*"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "field": "Microsoft.Compute/imagePublisher",
                        "equals": "microsoft-dsvm"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "equals": "dsvm-windows"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "field": "Microsoft.Compute/imagePublisher",
                        "equals": "microsoft-ads"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "in": [
                          "standard-data-science-vm",
                          "windows-data-science-vm"
                        ]
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "field": "Microsoft.Compute/imagePublisher",
                        "equals": "batch"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "equals": "rendering-windows2016"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "field": "Microsoft.Compute/imagePublisher",
                        "equals": "center-for-internet-security-inc"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "cis-windows-server-201*"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "field": "Microsoft.Compute/imagePublisher",
                        "equals": "pivotal"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "bosh-windows-server*"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "field": "Microsoft.Compute/imagePublisher",
                        "equals": "cloud-infrastructure-services"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "ad*"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "anyOf": [
                          {
                            "field": "Microsoft.Compute/virtualMachines/osProfile.windowsConfiguration",
                            "exists": "true"
                          },
                          {
                            "field": "Microsoft.Compute/virtualMachines/storageProfile.osDisk.osType",
                            "like": "Windows*"
                          }
                        ]
                      },
                      {
                        "anyOf": [
                          {
                            "field": "Microsoft.Compute/imageSku",
                            "exists": "false"
                          },
                          {
                            "allOf": [
                              {
                                "field": "Microsoft.Compute/imageSku",
                                "notLike": "2008*"
                              },
                              {
                                "field": "Microsoft.Compute/imageOffer",
                                "notLike": "SQL2008*"
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "allOf": [
              {
                "value": "[parameters('IncludeArcMachines')]",
                "equals": "true"
              },
              {
                "field": "type",
                "equals": "Microsoft.HybridCompute/machines"
              },
              {
                "field": "Microsoft.HybridCompute/imageOffer",
                "like": "windows*"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.GuestConfiguration/guestConfigurationAssignments",
          "name": "WindowsDefenderScanScheduleDaily",
          "existenceCondition": {
            "allOf": [
              {
                "field": "Microsoft.GuestConfiguration/guestConfigurationAssignments/complianceStatus",
                "equals": "Compliant"
              }
            ]
          }
        }
      }
    },
    "versions": [
      "1.3.0",
      "1.2.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/3810e389-1d92-4f77-9267-33bdcf0bd225",
  "name": "3810e389-1d92-4f77-9267-33bdcf0bd225"
}
Bylaw3810e389-1d92-4f77-9267-33bdcf0bd225.bylaw.ps1 · 101 lines
# Converted from ACAT_WindowsDefenderScanScheduleDaily_AINE.json by ConvertTo-Bylaw.
Policy '3810e389-1d92-4f77-9267-33bdcf0bd225' {

    Properties @{
        DisplayName   = '[Deprecated]: Windows machines should schedule Windows Defender to perform a scheduled scan every day'
        Description   = 'This policy is deprecated because Microsoft 365 App Compliance Program no longer checks schedule frequency on Windows machines. Learn more details about the latest M365 APP Compliance requirements at aka.ms/acat-cert2-seg-ops. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.'
        Category      = 'Guest Configuration'
        Version       = '1.3.0-deprecated'
        Deprecated    = $true
        PolicyVersion = '1.3.0'
        Mode          = 'Indexed'
        Metadata      = [ordered]@{ requiredProviders = @('Microsoft.GuestConfiguration'); guestConfiguration = [ordered]@{ name = 'WindowsDefenderScanScheduleDaily'; version = '1.11.*' } }
    }

    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'
    }
    Parameter Effect @{
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'Disabled'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of this policy'
    }

    Resource * {

        Require 'type, imagePublisher, imageSku and 3 more are as required' {
            AnyOf {
                Field type | Must -Not -Be 'Microsoft.Compute/virtualMachines' -IfPresent
                AllOf {
                    Field 'Microsoft.Compute/imagePublisher' | Must -Not -BeIn @('esri', 'incredibuild', 'MicrosoftDynamicsAX', 'MicrosoftSharepoint', 'MicrosoftVisualStudio', 'MicrosoftWindowsDesktop', 'MicrosoftWindowsServerHPCPack') -IfPresent
                    AnyOf {
                        Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftWindowsServer' -IfPresent
                        Field 'Microsoft.Compute/imageSku' | Must -BeLike '2008*'
                        Field 'Microsoft.Compute/imageSku' | Must -BeIn @('2012-Datacenter', '2012-Datacenter-smalldisk', '2012-R2-Datacenter', '2012-R2-Datacenter-smalldisk', '2016-Datacenter-Server-Core', '2016-Datacenter-Server-Core-smalldisk', '2016-Datacenter-smalldisk', '2016-Datacenter-with-Containers', '2016-Datacenter-with-RDSH', '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')
                    }
                    AnyOf {
                        Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftSQLServer' -IfPresent
                        Field 'Microsoft.Compute/imageOffer' | Must -BeLike 'SQL2008*'
                    }
                    AnyOf {
                        Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'microsoft-dsvm' -IfPresent
                        Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'dsvm-windows' -IfPresent
                    }
                    AnyOf {
                        Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'microsoft-ads' -IfPresent
                        Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('standard-data-science-vm', 'windows-data-science-vm') -IfPresent
                    }
                    AnyOf {
                        Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'batch' -IfPresent
                        Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'rendering-windows2016' -IfPresent
                    }
                    AnyOf {
                        Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'center-for-internet-security-inc' -IfPresent
                        Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike 'cis-windows-server-201*' -IfPresent
                    }
                    AnyOf {
                        Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'pivotal' -IfPresent
                        Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike 'bosh-windows-server*' -IfPresent
                    }
                    AnyOf {
                        Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'cloud-infrastructure-services' -IfPresent
                        Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike 'ad*' -IfPresent
                    }
                    AnyOf {
                        AllOf {
                            Field 'Microsoft.Compute/virtualMachines/osProfile.windowsConfiguration' | Must -Not -Exist
                            Field 'Microsoft.Compute/virtualMachines/storageProfile.osDisk.osType' | Must -Not -BeLike 'Windows*' -IfPresent
                        }
                        AllOf {
                            Field 'Microsoft.Compute/imageSku' | Must -Exist
                            AnyOf {
                                Field 'Microsoft.Compute/imageSku' | Must -BeLike '2008*'
                                Field 'Microsoft.Compute/imageOffer' | Must -BeLike 'SQL2008*'
                            }
                        }
                    }
                }
            }
        }

        Require 'type and imageOffer are as required' {
            AnyOf {
                Param IncludeArcMachines | Must -Not -Be 'true'
                Field type | Must -Not -Be 'Microsoft.HybridCompute/machines' -IfPresent
                Field 'Microsoft.HybridCompute/imageOffer' | Must -Not -BeLike 'windows*' -IfPresent
            }
        }
    }

    AuditIfNotExists 'Microsoft.GuestConfiguration/guestConfigurationAssignments' -Name 'WindowsDefenderScanScheduleDaily' -Effect (Param Effect) {
        Require 'complianceStatus is Compliant' {
            Field complianceStatus | Must -Be 'Compliant'
        }
    }
}

Source: built-in-policies/policyDefinitions/Guest Configuration/ACAT_WindowsDefenderScanScheduleDaily_AINE.json in Azure/azure-policy, under the MIT licence.