Search code examples
powershellazure-powershellpolicyazureportal

Azure policy- Check if initiative exists


I'm new to Azure policy and Powershell and I'm wondering if there's a way to check if:

  • an initiative exist, then do nothing.
  • if it doesn't exist, create it.

Any tip that can guide me to the solution will be appreciated


Solution

  • A policy initiative (which is also called a policy set), can be retrieved in Powershell's Az module with:

    Get-AzPolicySetDefinition | Select -Expand Properties
    

    or in the AZ CLI with:

    az policy set-definition list | ConvertFrom-Json