Search Azure policy aliases and sends output to an interactive table

If you want to create your own or to contribute to an existing GitHub project you are on the right page.

Use this script to quickly find and search for supported Azure Policy Aliases https://docs.microsoft.com/en-us/azure/governance/policy/concepts/definition-structure#aliases to use when authoring custom Azure Policy definitions.

Select one or more namespaces from the list –> Click OK

And then you will have all available aliases for the selected resources:

Here is the script:

 1# List all namespaces available in Azure Policy
 2$AllNamespaces = (Get-AzPolicyAlias -ListAvailable).Namespace | Sort-Object | Get-Unique
 3
 4# Select the namespaces you want to work with
 5$SelectedNamespaces = $null
 6$SelectedNamespaces = @()
 7
 8$AllNamespaces | Out-GridView -Title "Select one or more namespace. Found: $($AllNamespaces.count)" -OutputMode Multiple `
 9| Foreach-object { $SelectedNamespaces += $_ }
10
11# Get all aliases available in the selected namespaces
12$AvailableAliases = $null
13$AvailableAliases = @()
14
15Foreach ($Namespace in $SelectedNamespaces)
16{
17   $AvailableAliases += (Get-AzPolicyAlias -NamespaceMatch $Namespace).Aliases | Select-Object Name, DefaultPath
18}
19
20# List all aliases available in the selected namespaces
21$AvailableAliases | Out-GridView -Title "Available alias for selected ($($SelectedNamespaces.count)): $($SelectedNamespaces)" -OutputMode Single