Skip to content

Commit d8a8cd6

Browse files
authored
Merge pull request #100876 from DCtheGeek/dmc-policy-ghi45969
Fixes MicrosoftDocs/azure-docs#45969 - Change PowerShell to CLI
2 parents f2d23e2 + b4c531e commit d8a8cd6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

articles/governance/policy/assign-policy-azurecli.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Quickstart: New policy assignment with Azure CLI"
33
description: In this quickstart, you use Azure CLI to create an Azure Policy assignment to identify non-compliant resources.
4-
ms.date: 11/25/2019
4+
ms.date: 01/11/2020
55
ms.topic: quickstart
66
---
77
# Quickstart: Create a policy assignment to identify non-compliant resources with Azure CLI
@@ -72,19 +72,18 @@ The preceding command uses the following information:
7272
To view the resources that aren't compliant under this new assignment, get the policy assignment ID
7373
by running the following commands:
7474

75-
```azurepowershell-interactive
76-
$policyAssignment = Get-AzPolicyAssignment | Where-Object { $_.Properties.DisplayName -eq 'Audit VMs without managed disks Assignment' }
77-
$policyAssignment.PolicyAssignmentId
75+
```azurecli-interactive
76+
az policy assignment list --query "[?displayName=='Audit VMs without managed disks Assignment'].id"
7877
```
7978

8079
For more information about policy assignment IDs, see
81-
[Get-AzPolicyAssignment](/powershell/module/az.resources/get-azpolicyassignment).
80+
[az policy assignment](/cli/azure/policy/assignment).
8281

8382
Next, run the following command to get the resource IDs of the non-compliant resources that are
8483
output into a JSON file:
8584

8685
```console
87-
armclient post "/subscriptions/<subscriptionID>/resourceGroups/<rgName>/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2017-12-12-preview&$filter=IsCompliant eq false and PolicyAssignmentId eq '<policyAssignmentID>'&$apply=groupby((ResourceId))" > <json file to direct the output with the resource IDs into>
86+
armclient post "/subscriptions/<subscriptionID>/resourceGroups/<rgName>/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-09-01&$filter=IsCompliant eq false and PolicyAssignmentId eq '<policyAssignmentID>'&$apply=groupby((ResourceId))" > <json file to direct the output with the resource IDs into>
8887
```
8988

9089
Your results resemble the following example:

0 commit comments

Comments
 (0)