Bylaw

Gallery › Guest Configuration › Azure built-in policies

[Deprecated]: Audit Windows VMs that contain certificates expiring within the specified number of days

Converted Initiative Version 1.0.0-deprecated Deprecated

This initiative deploys the policy requirements and audits Windows virtual machines that contain certificates expiring within the specified number of days. For more information on Guest Configuration policies, please visit https://aka.ms/gcpol

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

Azure Policy JSONCertificateExpiration.json · 93 lines
{
  "properties": {
    "displayName": "[Deprecated]: Audit Windows VMs that contain certificates expiring within the specified number of days",
    "policyType": "BuiltIn",
    "description": "This initiative deploys the policy requirements and audits Windows virtual machines that contain certificates expiring within the specified number of days. For more information on Guest Configuration policies, please visit https://aka.ms/gcpol",
    "metadata": {
      "version": "1.0.0-deprecated",
      "category": "Guest Configuration",
      "deprecated": true
    },
    "version": "1.0.0",
    "parameters": {
      "CertificateStorePath": {
        "type": "string",
        "metadata": {
          "displayName": "Certificate store path",
          "description": "The path to the certificate store containing the certificates to check the expiration dates of. Default value is 'Cert:' which is the root certificate store path, so all certificates on the machine will be checked. Other example paths: 'Cert:\\LocalMachine', 'Cert:\\LocalMachine\\TrustedPublisher', 'Cert:\\CurrentUser'"
        },
        "defaultValue": "Cert:"
      },
      "ExpirationLimitInDays": {
        "type": "string",
        "metadata": {
          "displayName": "Expiration limit in days",
          "description": "An integer indicating the number of days within which to check for certificates that are expiring. For example, if this value is 30, any certificate expiring within the next 30 days will cause this policy to be non-compliant."
        },
        "defaultValue": "30"
      },
      "CertificateThumbprintsToInclude": {
        "type": "string",
        "metadata": {
          "displayName": "Certificate thumbprints to include",
          "description": "A semicolon-separated list of certificate thumbprints to check under the specified path. If a value is not specified, all certificates under the certificate store path will be checked. If a value is specified, no certificates other than those with the thumbprints specified will be checked. e.g. THUMBPRINT1;THUMBPRINT2;THUMBPRINT3"
        },
        "defaultValue": ""
      },
      "CertificateThumbprintsToExclude": {
        "type": "string",
        "metadata": {
          "displayName": "Certificate thumbprints to exclude",
          "description": "A semicolon-separated list of certificate thumbprints to ignore. e.g. THUMBPRINT1;THUMBPRINT2;THUMBPRINT3"
        },
        "defaultValue": ""
      },
      "IncludeExpiredCertificates": {
        "type": "string",
        "metadata": {
          "displayName": "Include expired certificates",
          "description": "Must be 'true' or 'false'. True indicates that any found certificates that have already expired will also make this policy non-compliant. False indicates that certificates that have expired will be be ignored."
        },
        "allowedValues": [
          "true",
          "false"
        ],
        "defaultValue": "false"
      }
    },
    "policyDefinitions": [
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/c5fbc59e-fb6f-494f-81e2-d99a671bdaa8",
        "definitionVersion": "1.*.*",
        "policyDefinitionReferenceId": "Deploy_CertificateExpiration",
        "parameters": {
          "CertificateStorePath": {
            "value": "[parameters('CertificateStorePath')]"
          },
          "ExpirationLimitInDays": {
            "value": "[parameters('ExpirationLimitInDays')]"
          },
          "CertificateThumbprintsToInclude": {
            "value": "[parameters('CertificateThumbprintsToInclude')]"
          },
          "CertificateThumbprintsToExclude": {
            "value": "[parameters('CertificateThumbprintsToExclude')]"
          },
          "IncludeExpiredCertificates": {
            "value": "[parameters('IncludeExpiredCertificates')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/9328f27e-611e-44a7-a244-39109d7d35ab",
        "definitionVersion": "1.*.*",
        "policyDefinitionReferenceId": "Audit_CertificateExpiration"
      }
    ],
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policySetDefinitions/b6f5e05c-0aaa-4337-8dd4-357c399d12ae",
  "name": "b6f5e05c-0aaa-4337-8dd4-357c399d12ae"
}
Bylawb6f5e05c-0aaa-4337-8dd4-357c399d12ae.bylaw.ps1 · 64 lines
# Converted from CertificateExpiration.json by ConvertTo-Bylaw.
Initiative 'b6f5e05c-0aaa-4337-8dd4-357c399d12ae' {

    Properties @{
        DisplayName   = '[Deprecated]: Audit Windows VMs that contain certificates expiring within the specified number of days'
        Description   = 'This initiative deploys the policy requirements and audits Windows virtual machines that contain certificates expiring within the specified number of days. For more information on Guest Configuration policies, please visit https://aka.ms/gcpol'
        Version       = '1.0.0-deprecated'
        Category      = 'Guest Configuration'
        Deprecated    = $true
        PolicyVersion = '1.0.0'
    }

    Parameter CertificateStorePath @{
        Type        = 'string'
        Default     = 'Cert:'
        DisplayName = 'Certificate store path'
        Description = 'The path to the certificate store containing the certificates to check the expiration dates of. Default value is ''Cert:'' which is the root certificate store path, so all certificates on the machine will be checked. Other example paths: ''Cert:\LocalMachine'', ''Cert:\LocalMachine\TrustedPublisher'', ''Cert:\CurrentUser'''
        JsonName    = 'CertificateStorePath'
    }
    Parameter ExpirationLimitInDays @{
        Type        = 'string'
        Default     = '30'
        DisplayName = 'Expiration limit in days'
        Description = 'An integer indicating the number of days within which to check for certificates that are expiring. For example, if this value is 30, any certificate expiring within the next 30 days will cause this policy to be non-compliant.'
        JsonName    = 'ExpirationLimitInDays'
    }
    Parameter CertificateThumbprintsToInclude @{
        Type        = 'string'
        Default     = ''
        DisplayName = 'Certificate thumbprints to include'
        Description = 'A semicolon-separated list of certificate thumbprints to check under the specified path. If a value is not specified, all certificates under the certificate store path will be checked. If a value is specified, no certificates other than those with the thumbprints specified will be checked. e.g. THUMBPRINT1;THUMBPRINT2;THUMBPRINT3'
        JsonName    = 'CertificateThumbprintsToInclude'
    }
    Parameter CertificateThumbprintsToExclude @{
        Type        = 'string'
        Default     = ''
        DisplayName = 'Certificate thumbprints to exclude'
        Description = 'A semicolon-separated list of certificate thumbprints to ignore. e.g. THUMBPRINT1;THUMBPRINT2;THUMBPRINT3'
        JsonName    = 'CertificateThumbprintsToExclude'
    }
    Parameter IncludeExpiredCertificates @{
        Type          = 'string'
        AllowedValues = @('true', 'false')
        Default       = 'false'
        DisplayName   = 'Include expired certificates'
        Description   = 'Must be ''true'' or ''false''. True indicates that any found certificates that have already expired will also make this policy non-compliant. False indicates that certificates that have expired will be be ignored.'
        JsonName      = 'IncludeExpiredCertificates'
    }

    PolicyDefinition @{
        Id          = 'c5fbc59e-fb6f-494f-81e2-d99a671bdaa8'
        ReferenceId = 'Deploy_CertificateExpiration'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            CertificateStorePath            = (Param CertificateStorePath)
            ExpirationLimitInDays           = (Param ExpirationLimitInDays)
            CertificateThumbprintsToInclude = (Param CertificateThumbprintsToInclude)
            CertificateThumbprintsToExclude = (Param CertificateThumbprintsToExclude)
            IncludeExpiredCertificates      = (Param IncludeExpiredCertificates)
        }
    }

    PolicyDefinition -Id '9328f27e-611e-44a7-a244-39109d7d35ab' -ReferenceId 'Audit_CertificateExpiration' -Version '1.*.*'
}

Members (2)

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