Skip to content

Commit

Permalink
Use last PowerState instance in Statuses for power status (#15941)
Browse files Browse the repository at this point in the history
* Use last PowerState instance in Statuses

* Update changelog
  • Loading branch information
DSakura207 committed Sep 24, 2021
1 parent 2511b07 commit b47f246
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Expand Up @@ -21,6 +21,7 @@
-->
## Upcoming Release
* Update Compute .NET SDK package reference to version 49.1.0
* Fixed a bug in `Get-AzVM` that caused incorrect power status output.

## Version 4.17.0
* Added new parameters `-LinuxConfigurationPatchMode`, `-WindowsConfigurationPatchMode`, and `-LinuxConfigurationProvisionVMAgent` to `Set-AzVmssOSProfile`
Expand Down
Expand Up @@ -14,6 +14,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -226,7 +227,8 @@ public override void ExecuteCmdlet()
var psstate = state.ToPSVirtualMachineInstanceView(psItem.ResourceGroupName, psItem.Name);
if (psstate != null && psstate.Statuses != null && psstate.Statuses.Count > 1)
{
psItem.PowerState = psstate.Statuses[1].DisplayStatus;
var powerStatus = psstate.Statuses.LastOrDefault(s => s.Code.StartsWith("PowerState"));
psItem.PowerState = powerStatus != null ? powerStatus.DisplayStatus : InfoNotAvailable;
}
else
{
Expand Down

0 comments on commit b47f246

Please sign in to comment.