Skip to content

Commit 8f8de25

Browse files
Indent PowerShell code block
1 parent d6807e5 commit 8f8de25

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

articles/governance/resource-graph/paginate-powershell.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 'Paginate Azure Resource Graph query results using Azure PowerShell'
33
description: In this quickstart, you control the volume Azure Resource Graph query output by using pagination in Azure PowerShell.
4-
ms.date: 11/10/2022
4+
ms.date: 11/11/2022
55
ms.topic: quickstart
66
ms.author: timwarner
77
author: timwarner-msft
@@ -82,34 +82,34 @@ We'll then configure the query to return five records (VMs) at a time.
8282

8383
1. Update the query to implement the `skipToken` parameter and return 5 VMs in each batch:
8484

85-
```powershell
86-
$kqlQuery = "Resources | join kind=leftouter (ResourceContainers | where
87-
type=='microsoft.resources/subscriptions' | project subscriptionName = name,subscriptionId) on
88-
subscriptionId | where type =~ 'Microsoft.Compute/virtualMachines' | project VMResourceId = id,
89-
subscriptionName, resourceGroup,name"
85+
```powershell
86+
$kqlQuery = "Resources | join kind=leftouter (ResourceContainers | where
87+
type=='microsoft.resources/subscriptions' | project subscriptionName = name,subscriptionId) on
88+
subscriptionId | where type =~ 'Microsoft.Compute/virtualMachines' | project VMResourceId = id,
89+
subscriptionName, resourceGroup,name"
9090
91-
$batchSize = 5
92-
$skipResult = 0
91+
$batchSize = 5
92+
$skipResult = 0
9393
94-
[System.Collections.Generic.List[string]]$kqlResult
94+
[System.Collections.Generic.List[string]]$kqlResult
9595
96-
while ($true) {
96+
while ($true) {
9797
98-
if ($skipResult -gt 0) {
99-
$graphResult = Search-AzGraph -Query $kqlQuery -First $batchSize -SkipToken $graphResult.SkipToken
100-
}
101-
else {
102-
$graphResult = Search-AzGraph -Query $kqlQuery -First $batchSize
103-
}
98+
if ($skipResult -gt 0) {
99+
$graphResult = Search-AzGraph -Query $kqlQuery -First $batchSize -SkipToken $graphResult.SkipToken
100+
}
101+
else {
102+
$graphResult = Search-AzGraph -Query $kqlQuery -First $batchSize
103+
}
104104
105-
$kqlResult += $graphResult.data
105+
$kqlResult += $graphResult.data
106106
107-
if ($graphResult.data.Count -lt $batchSize) {
108-
break;
107+
if ($graphResult.data.Count -lt $batchSize) {
108+
break;
109+
}
110+
$skipResult += $skipResult + $batchSize
109111
}
110-
$skipResult += $skipResult + $batchSize
111-
}
112-
```
112+
```
113113

114114
## Clean up resources
115115

0 commit comments

Comments
 (0)