How to set policy Category for policy definition using New-AzureRmPolicyDefinition cmdlet?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@JozoSlejko That's something that would typically be in the cmdlet reference page (https://docs.microsoft.com/powershell/module/azurerm.resources/new-azurermpolicydefinition). I believe that Category is passed through the Metadata parameter, but will validate with engineering. I'll also ask if they can add an example for metadata to include category. Thanks for the feedback!
@MicrosoftDocs/azure-cxp-triage Please assign to me, label 'product-question', and #in-progress
@JozoSlejko Got confirmation, Category can be used with Metadata. Metadata takes a string, but that string is JSON that contains the property key/value pairs. So, something like this:
-Metadata '{"Category":"Virtual Machine"}'
We'll get the ref content updated with an example to cover using Metadata like this that includes Category. Thanks again for the feedback!
@MicrosoftDocs/azure-cxp-triage #please-close
Azure/azure-powershell#7829 Here's the link to the PR to update the example in the ref content.
If i use the example (_New-AzureRmPolicyDefinition -Name 'VMPolicyDefinition' -Metadata '{"Category":"Virtual Machine"}' -Policy '{"if":{"source":"action","equals":"Microsoft.Compute/virtualMachines/write"},"then":{"effect":"deny"}}'_) to create a policy, the Category is still empty:

@Obiwan72 The issue appears to be that 'category' is case-sensitive within the Portal UX. Please use all lower-case 'category' and validate that solves the issue for you of it not showing up in Portal UX.
Yes, with category in lower-case it works. Thx!
Most helpful comment
Yes, with category in lower-case it works. Thx!