Skip to content

Commit edd6562

Browse files
authored
Merge pull request #7365 from jabbera/fix-vm-paging-by-rg
Fix Get-AzureRmVM paging with ResourceGroupName
2 parents 698f45a + 8699db2 commit edd6562

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/ResourceManager/Compute/Commands.Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Additional information about change #1
2020
-->
2121
## Current Release
22+
* Fix Get-AzureRmVM -ResourceGroupName <rg> to return more than 50 results if needed
2223
* Added an example of the `SimpleParameterSet` to New-AzureRmVmss cmdlet help.
2324
* Fixed a typo in the Azure Disk Encryption progress message
2425

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Operation/GetAzureVMCommand.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,21 @@ public override void ExecuteCmdlet()
158158
.GetAwaiter().GetResult();
159159

160160
var psResultListStatus = new List<PSVirtualMachineListStatus>();
161-
psResultListStatus = GetPowerstate(vmListResult, psResultListStatus);
161+
162+
while (vmListResult != null)
163+
{
164+
psResultListStatus = GetPowerstate(vmListResult, psResultListStatus);
165+
166+
if (!string.IsNullOrEmpty(vmListResult.Body.NextPageLink))
167+
{
168+
vmListResult = this.VirtualMachineClient.ListNextWithHttpMessagesAsync(vmListResult.Body.NextPageLink)
169+
.GetAwaiter().GetResult();
170+
}
171+
else
172+
{
173+
vmListResult = null;
174+
}
175+
}
162176

163177
if (this.Status.IsPresent)
164178
{

0 commit comments

Comments
 (0)