Skip to content

Commit 45e264c

Browse files
authored
Merge pull request #8447 from vivlingaiah/vivekl/minorBugFixes
[GuestConfiguration] Fix error messages, fix redundant get all assign…
2 parents 1229c76 + 9d1d430 commit 45e264c

File tree

30 files changed

+4401
-5689
lines changed

30 files changed

+4401
-5689
lines changed

src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/GetVmGuestPolicyStatusHistoryTests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Get guest configuration policy status history by Vm name scope
1919
function Get-AzVMGuestPolicyStatusHistory-VmNameScope
2020
{
2121
$rgName = "vivga"
22-
$vmName = "vivga0"
22+
$vmName = "Viv1809SDDC"
2323

2424
$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName
2525
Assert-NotNull $historicalStatuses
@@ -33,7 +33,7 @@ Get guest configuration policy status history by Initiative id scope
3333
function Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope
3434
{
3535
$rgName = "vivga"
36-
$vmName = "vivga0"
36+
$vmName = "Viv1809SDDC"
3737
$initiativeId = "/providers/Microsoft.Authorization/policySetDefinitions/25ef9b72-4af2-4501-acd1-fc814e73dde1"
3838

3939
$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -InitiativeId $initiativeId
@@ -48,7 +48,7 @@ Get guest configuration policy status history by Initiative name scope
4848
function Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope
4949
{
5050
$rgName = "vivga"
51-
$vmName = "vivga0"
51+
$vmName = "Viv1809SDDC"
5252
$initiativeName = "25ef9b72-4af2-4501-acd1-fc814e73dde1"
5353

5454
$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
@@ -63,7 +63,7 @@ Get guest configuration policy by vmName scope, using ShowOnlyChange switch
6363
function Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope
6464
{
6565
$rgName = "vivga"
66-
$vmName = "vivga0"
66+
$vmName = "Viv1809SDDC"
6767

6868
$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -ShowOnlyChange
6969
Assert-NotNull $historicalStatuses

src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/GetVmGuestPolicyReportTests.cs renamed to src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/GetVmGuestPolicyStatusTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ namespace Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests
2121
using Xunit;
2222

2323

24-
public class GetVmGuestPolicyReportTests
24+
public class GetVmGuestPolicyStatusTests
2525
{
2626
private readonly XunitTracingInterceptor _logger;
2727

28-
public GetVmGuestPolicyReportTests(Xunit.Abstractions.ITestOutputHelper output)
28+
public GetVmGuestPolicyStatusTests(Xunit.Abstractions.ITestOutputHelper output)
2929
{
3030
_logger = new XunitTracingInterceptor(output);
3131
XunitTracingInterceptor.AddToContext(_logger);
@@ -36,28 +36,28 @@ public GetVmGuestPolicyReportTests(Xunit.Abstractions.ITestOutputHelper output)
3636
[Trait(Category.AcceptanceType, Category.CheckIn)]
3737
public void VmNameScope()
3838
{
39-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyReport-VmNameScope");
39+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-VmNameScope");
4040
}
4141

4242
[Fact]
4343
[Trait(Category.AcceptanceType, Category.CheckIn)]
4444
public void InitiativeIdScope()
4545
{
46-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyReport-InitiativeIdScope");
46+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeIdScope");
4747
}
4848

4949
[Fact]
5050
[Trait(Category.AcceptanceType, Category.CheckIn)]
5151
public void InitiativeNameScope()
5252
{
53-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyReport-InitiativeNameScope");
53+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeNameScope");
5454
}
5555

5656
[Fact]
5757
[Trait(Category.AcceptanceType, Category.CheckIn)]
58-
public void ReportIdScope()
58+
public void IdScope()
5959
{
60-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyReport-ReportIdScope");
60+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-IdScope");
6161
}
6262
}
6363
}

src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/GetVmGuestPolicyReportTests.ps1 renamed to src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/GetVmGuestPolicyStatusTests.ps1

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
.SYNOPSIS
1717
Get guest configuration policy report by Vm name scope
1818
#>
19-
function Get-AzVMGuestPolicyReport-VmNameScope
19+
function Get-AzVMGuestPolicyStatus-VmNameScope
2020
{
2121
$rgName = "vivga"
22-
$vmName = "vivga0"
22+
$vmName = "Viv1809SDDC"
2323

24-
$reports = Get-AzVMGuestPolicyReport -ResourceGroupName $rgName -VMName $vmName
24+
$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName
2525
Assert-NotNull $reports
2626
Assert-True { $reports.Count -gt 0 }
2727
}
@@ -30,13 +30,13 @@ function Get-AzVMGuestPolicyReport-VmNameScope
3030
.SYNOPSIS
3131
Get guest configuration policy report by Initiative id scope
3232
#>
33-
function Get-AzVMGuestPolicyReport-InitiativeIdScope
33+
function Get-AzVMGuestPolicyStatus-InitiativeIdScope
3434
{
3535
$rgName = "vivga"
36-
$vmName = "vivga0"
36+
$vmName = "Viv1809SDDC"
3737
$initiativeId = "/providers/Microsoft.Authorization/policySetDefinitions/25ef9b72-4af2-4501-acd1-fc814e73dde1"
3838

39-
$reports = Get-AzVMGuestPolicyReport -ResourceGroupName $rgName -VMName $vmName -InitiativeId $initiativeId
39+
$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeId $initiativeId
4040
Assert-NotNull $reports
4141
Assert-True { $reports.Count -gt 0 }
4242
}
@@ -45,32 +45,32 @@ function Get-AzVMGuestPolicyReport-InitiativeIdScope
4545
.SYNOPSIS
4646
Get guest configuration policy report by Initiative name scope
4747
#>
48-
function Get-AzVMGuestPolicyReport-InitiativeNameScope
48+
function Get-AzVMGuestPolicyStatus-InitiativeNameScope
4949
{
5050
$rgName = "vivga"
51-
$vmName = "vivga0"
51+
$vmName = "Viv1809SDDC"
5252
$initiativeName = "25ef9b72-4af2-4501-acd1-fc814e73dde1"
5353

54-
$reports = Get-AzVMGuestPolicyReport -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
54+
$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
5555
Assert-NotNull $reports
5656
Assert-True { $reports.Count -gt 0 }
5757
}
5858

5959
<#
6060
.SYNOPSIS
61-
Get guest configuration policy by reportId scope
61+
Get guest configuration policy by Id scope
6262
#>
63-
function Get-AzVMGuestPolicyReport-ReportIdScope
63+
function Get-AzVMGuestPolicyStatus-IdScope
6464
{
6565
$rgName = "vivga"
66-
$vmName = "vivga0"
66+
$vmName = "Viv1809SDDC"
6767
$initiativeName = "25ef9b72-4af2-4501-acd1-fc814e73dde1"
68-
$reports = Get-AzVMGuestPolicyReport -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
68+
$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
6969
Assert-NotNull $reports
7070
Assert-True { $reports.Count -gt 0 }
7171

72-
$reportId= $reports[0].LatestReportId;
72+
$Id= $reports[0].Id;
7373

74-
$report = Get-AzVMGuestPolicyReport -ReportId $reportId
74+
$report = Get-AzVMGuestPolicyStatus -Id $Id
7575
Assert-NotNull $report
7676
}

src/GuestConfiguration/GuestConfiguration.Test/SessionRecords/Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests.GetVmGuestPolicyReportTests/VmNameScope.json

Lines changed: 0 additions & 2807 deletions
This file was deleted.

src/GuestConfiguration/GuestConfiguration.Test/SessionRecords/Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests.GetVmGuestPolicyStatusHistoryTests/InitiativeIdScope.json

Lines changed: 71 additions & 71 deletions
Large diffs are not rendered by default.

src/GuestConfiguration/GuestConfiguration.Test/SessionRecords/Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests.GetVmGuestPolicyStatusHistoryTests/InitiativeNameScope.json

Lines changed: 68 additions & 68 deletions
Large diffs are not rendered by default.

src/GuestConfiguration/GuestConfiguration.Test/SessionRecords/Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests.GetVmGuestPolicyStatusHistoryTests/ShowOnlyChangeSwitchVmNameScope.json

Lines changed: 381 additions & 1089 deletions
Large diffs are not rendered by default.

src/GuestConfiguration/GuestConfiguration.Test/SessionRecords/Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests.GetVmGuestPolicyStatusHistoryTests/VmNameScope.json

Lines changed: 381 additions & 1089 deletions
Large diffs are not rendered by default.
Lines changed: 79 additions & 79 deletions
Large diffs are not rendered by default.
Lines changed: 70 additions & 70 deletions
Large diffs are not rendered by default.
Lines changed: 67 additions & 67 deletions
Large diffs are not rendered by default.

src/GuestConfiguration/GuestConfiguration.Test/SessionRecords/Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests.GetVmGuestPolicyStatusTests/ReportIdScope.json

Lines changed: 329 additions & 0 deletions
Large diffs are not rendered by default.

src/GuestConfiguration/GuestConfiguration.Test/SessionRecords/Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests.GetVmGuestPolicyStatusTests/VmNameScope.json

Lines changed: 2477 additions & 0 deletions
Large diffs are not rendered by default.

src/GuestConfiguration/GuestConfiguration/Az.GuestConfiguration.psd1

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# RootModule = ''
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.10.1'
15+
ModuleVersion = '0.10.2'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Core', 'Desktop'
@@ -30,7 +30,7 @@ CompanyName = 'Microsoft Corporation'
3030
Copyright = 'Microsoft Corporation. All rights reserved.'
3131

3232
# Description of the functionality provided by this module
33-
Description = 'Microsoft Azure PowerShell - Guest Configuration service cmdlets for Azure Resource Manager. Allows querying VM compliance statuses for initiatives (part of Azure Policy) of category "Guest configuration", compliance reasons, compliance status history. For more information, please visit: https://aka.ms/guestconfigcmdlets'
33+
Description = 'Microsoft Azure PowerShell - Guest Configuration service cmdlets for Azure Resource Manager. Allows querying VM compliance statuses for initiatives (part of Azure Policy) of category "Guest configuration", compliance reasons, compliance status history. For more information, please visit: https://aka.ms/guestconfigcmdlets '
3434

3535
# Minimum version of the Windows PowerShell engine required by this module
3636
PowerShellVersion = '5.1'
@@ -72,7 +72,7 @@ NestedModules = @('.\Microsoft.Azure.PowerShell.Cmdlets.GuestConfiguration.dll')
7272
FunctionsToExport = @()
7373

7474
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75-
CmdletsToExport = 'Get-AzVMGuestPolicyReport', 'Get-AzVMGuestPolicyStatusHistory'
75+
CmdletsToExport = 'Get-AzVMGuestPolicyStatus', 'Get-AzVMGuestPolicyStatusHistory'
7676

7777
# Variables to export from this module
7878
# VariablesToExport = @()
@@ -104,14 +104,10 @@ PrivateData = @{
104104
# IconUri = ''
105105

106106
# ReleaseNotes of this module
107-
ReleaseNotes = '* Initial release of Az.GuestConfiguration module. Provides these two cmdlets.
108-
* Get-AzVMGuestPolicyReport
109-
* Provides compliance status of a VM in a resource group, compliance reasons.
110-
* Get-AzVMGuestPolicyStatusHistory:
111-
* Provides historical compliance statuses of a VM in a resource group, for a maximum of past 14 days.'
107+
ReleaseNotes = 'General bug fixes and Cmdlet Get-AzVMGuestPolicyReport renamed to Get-AzVMGuestPolicyStatus to keep it consistent with the Azure portal and to avoid user confusion.'
112108

113109
# Prerelease string of this module
114-
# Prerelease = ''
110+
#Prerelease = ''
115111

116112
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
117113
# RequireLicenseAcceptance = $false
@@ -129,5 +125,4 @@ PrivateData = @{
129125
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
130126
# DefaultCommandPrefix = ''
131127

132-
}
133-
128+
}

src/GuestConfiguration/GuestConfiguration/ChangeLog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@
1919
-->
2020
## Upcoming Release
2121

22+
## Version 0.10.2
23+
- General bug fixes.
24+
- Rename cmdlet Get-AzVMGuestPolicyReport to Get-AzVMGuestPolicyStatus to keep it consistent with the Azure portal and to avoid user confusion.
25+
2226
## Version 0.10.1
2327
* Initial release of Az.GuestConfiguration module. Provides these two cmdlets.
24-
* Get-AzVMGuestPolicyReport
28+
* Get-AzVMGuestPolicyStatus
2529
* Provides compliance status of a VM in a resource group, compliance reasons.
2630
* Get-AzVMGuestPolicyStatusHistory:
2731
* Provides historical compliance statuses of a VM in a resource group, for a maximum of past 14 days.

src/GuestConfiguration/GuestConfiguration/Cmdlets/GetAzureRmVMGuestPolicyReport.cs renamed to src/GuestConfiguration/GuestConfiguration/Cmdlets/GetAzVMGuestPolicyStatus.cs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ namespace Microsoft.Azure.Commands.GuestConfiguration.Cmdlets
2020
using Microsoft.Azure.Commands.GuestConfiguration.Common;
2121
using Microsoft.Azure.Commands.GuestConfiguration.Models;
2222
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
23-
using Microsoft.Azure.Management.GuestConfiguration.Models;
2423

2524
/// <summary>
2625
/// Gets Vm Guest Policy reports (GuestConfiguration policy reports)
2726
/// </summary>
28-
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VMGuestPolicyReport", DefaultParameterSetName = ParameterSetNames.VmNameScope),
29-
OutputType(typeof(IList<GuestConfigurationAssignmentReport>))]
30-
public class GetAzureRmVMGuestPolicyReport : GuestConfigurationCmdletBase
27+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzurePrefix + "VMGuestPolicyStatus", DefaultParameterSetName = ParameterSetNames.VmNameScope)]
28+
[OutputType(typeof(PolicyStatusDetailed))]
29+
public class GetAzVMGuestPolicyStatus : GuestConfigurationCmdletBase
3130
{
3231
[Parameter(ParameterSetName = ParameterSetNames.VmNameScope, Mandatory = true, Position = 0, HelpMessage = ParameterHelpMessages.ResourceGroupName)]
3332
[Parameter(ParameterSetName = ParameterSetNames.InitiativeIdScope, Mandatory = true, Position = 0, HelpMessage = ParameterHelpMessages.ResourceGroupName)]
@@ -50,46 +49,55 @@ public class GetAzureRmVMGuestPolicyReport : GuestConfigurationCmdletBase
5049
[ValidateNotNullOrEmpty]
5150
public string InitiativeId { get; set; }
5251

53-
[Parameter(ParameterSetName = ParameterSetNames.ReportIdScope, Mandatory = true, Position = 0, HelpMessage = ParameterHelpMessages.ReportId)]
52+
[Parameter(ParameterSetName = ParameterSetNames.IdScope, Mandatory = true, Position = 0, HelpMessage = ParameterHelpMessages.Id)]
5453
[ValidateNotNullOrEmpty]
55-
public string ReportId { get; set; }
54+
public string Id { get; set; }
5655

5756
/// <summary>
5857
/// Executes the cmdlet
5958
/// </summary>
6059
public override void ExecuteCmdlet()
6160
{
62-
IEnumerable<GuestConfigurationPolicyAssignmentReport> gcPolicyAssignmentReports = null;
63-
61+
IEnumerable<PolicyStatusDetailed> gcPolicyAssignmentReports = null;
6462
switch (ParameterSetName)
6563
{
64+
// Process results for cmdlet
6665
case ParameterSetNames.InitiativeNameScope:
67-
gcPolicyAssignmentReports = GetAllGuestConfigurationAssignmentReportsByInitiativeName(ResourceGroupName, VMName, InitiativeName, false);
66+
// get all gcrp assignments first
67+
var gcrpAssignments = GetAllGCRPAssignments(ResourceGroupName, VMName);
68+
69+
gcPolicyAssignmentReports = GetPolicyStatusesDetailedByInitiativeName(ResourceGroupName, VMName, InitiativeName, gcrpAssignments);
6870
if(gcPolicyAssignmentReports == null || gcPolicyAssignmentReports.Count() > 0)
6971
{
7072
WriteObject(gcPolicyAssignmentReports, true);
7173
}
7274
break;
7375

7476
case ParameterSetNames.InitiativeIdScope:
75-
gcPolicyAssignmentReports = GetAllGuestConfigurationAssignmentReportsByInitiativeId(ResourceGroupName, VMName, InitiativeId, false);
77+
// get all gcrp assignments first
78+
gcrpAssignments = GetAllGCRPAssignments(ResourceGroupName, VMName);
79+
80+
gcPolicyAssignmentReports = GetPolicyStatusesDetailedByInitiativeId(ResourceGroupName, VMName, InitiativeId, false, gcrpAssignments);
7681

7782
if (gcPolicyAssignmentReports == null || gcPolicyAssignmentReports.Count() > 0)
7883
{
7984
WriteObject(gcPolicyAssignmentReports, true);
8085
}
8186
break;
8287

83-
case ParameterSetNames.ReportIdScope:
84-
var policyReport = GetGuestConfigurationAssignmentReportById(ReportId);
88+
case ParameterSetNames.IdScope:
89+
var policyReport = GetPolicyStatusDetailedByReportId(Id);
8590
if (policyReport != null)
8691
{
8792
WriteObject(policyReport);
8893
}
8994
break;
9095

9196
case ParameterSetNames.VmNameScope:
92-
gcPolicyAssignmentReports = GetAllGuestConfigurationAssignmentReports(ResourceGroupName, VMName, false);
97+
// get all gcrp assignments first
98+
gcrpAssignments = GetAllGCRPAssignments(ResourceGroupName, VMName);
99+
100+
gcPolicyAssignmentReports = GetPolicyStatusesDetailed(ResourceGroupName, VMName, gcrpAssignments, false);
93101
if (gcPolicyAssignmentReports == null || gcPolicyAssignmentReports.Count() > 0)
94102
{
95103
WriteObject(gcPolicyAssignmentReports, true);

src/GuestConfiguration/GuestConfiguration/Cmdlets/GetAzureRmVMGuestPolicyStatusHistory.cs renamed to src/GuestConfiguration/GuestConfiguration/Cmdlets/GetAzVMGuestPolicyStatusHistory.cs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ namespace Microsoft.Azure.Commands.GuestConfiguration.Cmdlets
2020
using Microsoft.Azure.Commands.GuestConfiguration.Common;
2121
using Microsoft.Azure.Commands.GuestConfiguration.Models;
2222
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
23-
using Microsoft.Azure.Management.GuestConfiguration.Models;
2423

2524
/// <summary>
2625
/// Gets Vm Guest Policy reports (GuestConfiguration policy reports)
2726
/// </summary>
28-
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VMGuestPolicyStatusHistory", DefaultParameterSetName = ParameterSetNames.VmNameScope),
29-
OutputType(typeof(IList<GuestConfigurationAssignmentReport>))]
30-
public class GetAzureRmVMGuestPolicyStatusHistory : GuestConfigurationCmdletBase
27+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzurePrefix + "VMGuestPolicyStatusHistory", DefaultParameterSetName = ParameterSetNames.VmNameScope)]
28+
[OutputType(typeof(PolicyStatus))]
29+
public class GetAzVMGuestPolicyStatusHistory : GuestConfigurationCmdletBase
3130
{
3231
[Parameter(ParameterSetName = ParameterSetNames.VmNameScope, Mandatory = true, Position = 0, HelpMessage = ParameterHelpMessages.ResourceGroupName)]
3332
[Parameter(ParameterSetName = ParameterSetNames.InitiativeIdScope, Mandatory = true, Position = 0, HelpMessage = ParameterHelpMessages.ResourceGroupName)]
@@ -60,32 +59,36 @@ public class GetAzureRmVMGuestPolicyStatusHistory : GuestConfigurationCmdletBase
6059
/// </summary>
6160
public override void ExecuteCmdlet()
6261
{
63-
IEnumerable<GuestConfigurationPolicyAssignmentReport> gcPolicyAssignmentReports = null;
62+
IEnumerable<PolicyStatus> policyStatuses = null;
63+
64+
// get all gcrp assignments first
65+
var gcrpAssignments = GetAllGCRPAssignments(ResourceGroupName, VMName);
6466

6567
switch (ParameterSetName)
6668
{
67-
case ParameterSetNames.InitiativeNameScope:
68-
gcPolicyAssignmentReports = GetAllGuestConfigurationAssignmentReportsByInitiativeName(ResourceGroupName, VMName, InitiativeName, true, ShowOnlyChange.IsPresent);
69-
if (gcPolicyAssignmentReports == null || gcPolicyAssignmentReports.Count() > 0)
69+
// Process results for cmdlet
70+
case ParameterSetNames.InitiativeNameScope:
71+
policyStatuses = GetPolicyStatusHistory(ResourceGroupName, VMName, gcrpAssignments, InitiativeName, ShowOnlyChange.IsPresent);
72+
if (policyStatuses == null || policyStatuses.Count() > 0)
7073
{
71-
WriteObject(gcPolicyAssignmentReports, true);
74+
WriteObject(policyStatuses, true);
7275
}
7376
break;
7477

7578
case ParameterSetNames.InitiativeIdScope:
76-
gcPolicyAssignmentReports = GetAllGuestConfigurationAssignmentReportsByInitiativeId(ResourceGroupName, VMName, InitiativeId, true, ShowOnlyChange.IsPresent);
79+
policyStatuses = GetPolicyStatusHistoryByInitiativeId(ResourceGroupName, VMName, InitiativeId, gcrpAssignments, ShowOnlyChange.IsPresent);
7780

78-
if (gcPolicyAssignmentReports == null || gcPolicyAssignmentReports.Count() > 0)
81+
if (policyStatuses == null || policyStatuses.Count() > 0)
7982
{
80-
WriteObject(gcPolicyAssignmentReports, true);
83+
WriteObject(policyStatuses, true);
8184
}
8285
break;
8386

8487
case ParameterSetNames.VmNameScope:
85-
gcPolicyAssignmentReports = GetAllGuestConfigurationAssignmentReports(ResourceGroupName, VMName, true, ShowOnlyChange.IsPresent);
86-
if (gcPolicyAssignmentReports == null || gcPolicyAssignmentReports.Count() > 0)
88+
policyStatuses = GetPolicyStatusHistory(ResourceGroupName, VMName, gcrpAssignments, null, ShowOnlyChange.IsPresent);
89+
if (policyStatuses == null || policyStatuses.Count() > 0)
8790
{
88-
WriteObject(gcPolicyAssignmentReports, true);
91+
WriteObject(policyStatuses, true);
8992
}
9093
break;
9194
}

0 commit comments

Comments
 (0)