none
Retrieve all azure policy displayName values using AzureRmPolicyDefinition - Powershell 5 RRS feed

  • Question

  • Trying to get a list of all the Azure policy display names using Get-AzureRMPolicyDefinition.  I can select it down to the "Properties" property but not sure how to pull the displayName out for each policy.    Is there a good way to pull out just the "displayname" value for each policy?

    Get-AzureRmPolicyDefinition | select -first 1 -property Properties

    Properties
    ----------
    @{displayName=[Preview]: Deploy Log Analytics Agent for Linux VMs; policyType=BuiltIn; mode=Indexed; description=Deploy Log Analytics Agent for Linux VMs if the VM Image (OS) is in the list defined and the agent is not installed.; metadata=; parameters=; policyRule=}


    Friday, September 21, 2018 10:13 PM

Answers

  • You may try the following cmdlet to retrieve all azure policy displayName values using AzureRmPolicyDefinition:

    Get-AzureRmPolicyDefinition | Select -ExpandProperty "Properties" | Select -ExpandProperty "displayName"
    
    OR
    
    Get-AzureRmPolicyDefinition | Select -ExpandProperty "Properties" | Select-Object "displayName"

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here

    Saturday, September 22, 2018 7:00 AM
    Moderator

All replies

  • You may try the following cmdlet to retrieve all azure policy displayName values using AzureRmPolicyDefinition:

    Get-AzureRmPolicyDefinition | Select -ExpandProperty "Properties" | Select -ExpandProperty "displayName"
    
    OR
    
    Get-AzureRmPolicyDefinition | Select -ExpandProperty "Properties" | Select-Object "displayName"

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here

    Saturday, September 22, 2018 7:00 AM
    Moderator
  • Just for info, i have published a script that extract in csv files your Azure policies that match a given suffix name.

    https://github.com/JamesDLD/AzureRm-PowerShell/blob/master/Audit-AzPolicies.ps1

    Note: I am using the last version of the Azure module "Az", if you want to use AzureRm just replace"Get-Az" by "Get-AzureRm".





    Saturday, December 1, 2018 11:34 AM
  • AZ Module Equivalent:

    Get-AzPolicyDefinition | Select -ExpandProperty "Properties" | Select -ExpandProperty "displayName"

    Friday, August 16, 2019 9:28 PM
  • Hi Scott_m,

    Thanks for sharing this information! It will help any others that are looking to achieve the same.

    Monday, August 19, 2019 6:06 AM
    Moderator