From 05d8ff19fbb71181b5dfbcb3c267152bbe3fbfe1 Mon Sep 17 00:00:00 2001 From: "ITACS\\mk" Date: Tue, 21 Nov 2023 09:23:43 +0100 Subject: [PATCH 1/3] Export AADRoleSetting with Filter and Sort --- CHANGELOG.md | 3 +++ .../MSFT_AADRoleSetting/MSFT_AADRoleSetting.psm1 | 3 ++- .../Microsoft365DSC.AADRoleSetting.Tests.ps1 | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74bdc00ea9..f4d6847ddf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change log for Microsoft365DSC +* AADRoleSetting + * Export sorted by DisplayName for better comparison + * Enable Filter property to be used on export # 1.23.1115.1 * AADApplication diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleSetting/MSFT_AADRoleSetting.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleSetting/MSFT_AADRoleSetting.psm1 index 4353dd8ce8..117d2e66d8 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleSetting/MSFT_AADRoleSetting.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleSetting/MSFT_AADRoleSetting.psm1 @@ -1283,6 +1283,7 @@ function Test-TargetResource [Switch] $ManagedIdentity ) + $Script:ExportMode = $false #Ensure the proper dependencies are installed in the current environment. Confirm-M365DSCDependencies @@ -1379,7 +1380,7 @@ function Export-TargetResource try { $Script:ExportMode = $true - [array] $Script:exportedInstances = Get-MgBetaRoleManagementDirectoryRoleDefinition -ErrorAction Stop + [array] $Script:exportedInstances = Get-MgBetaRoleManagementDirectoryRoleDefinition -Filter $Filter -Sort DisplayName -ErrorAction Stop $i = 1 $dscContent = '' Write-Host "`r`n" -NoNewline diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADRoleSetting.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADRoleSetting.Tests.ps1 index 31cb22bf3e..5b68626cd5 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADRoleSetting.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADRoleSetting.Tests.ps1 @@ -660,6 +660,15 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { It 'Should reverse engineer resource from the export method' { $result = Export-TargetResource @testParams + Should -Invoke -Scope It -CommandName 'Get-MgBetaRoleManagementDirectoryRoleDefinition' -ParameterFilter { $Filter -eq '' -and $Sort -eq 'DisplayName' } -Times 1 + $result | Should -Not -BeNullOrEmpty + } + + It 'Should reverse engineer resource from the export method with a filter' { + $testParams.Filter = "displayName eq 'Role1'" + + $result = Export-TargetResource @testParams + Should -Invoke -Scope It -CommandName 'Get-MgBetaRoleManagementDirectoryRoleDefinition' -ParameterFilter { $Filter -eq "displayName eq 'Role1'" -and $Sort -eq 'DisplayName' } -Times 1 $result | Should -Not -BeNullOrEmpty } } From c6cb32a7bb1c4551ff3f8a952556e2630262d7ef Mon Sep 17 00:00:00 2001 From: "ITACS\\mk" Date: Tue, 21 Nov 2023 09:29:25 +0100 Subject: [PATCH 2/3] Update ChangeLog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4d6847ddf..50d046dd3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * AADRoleSetting * Export sorted by DisplayName for better comparison * Enable Filter property to be used on export + FIXES [#3919](https://github.com/microsoft/Microsoft365DSC/issues/3919) # 1.23.1115.1 * AADApplication From 1bc28e6e3b9187f92742f16557d7b831e25352e1 Mon Sep 17 00:00:00 2001 From: "ITACS\\mk" Date: Thu, 23 Nov 2023 08:38:43 +0100 Subject: [PATCH 3/3] update Change log with new line --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50d046dd3a..057cb76816 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Export sorted by DisplayName for better comparison * Enable Filter property to be used on export FIXES [#3919](https://github.com/microsoft/Microsoft365DSC/issues/3919) + # 1.23.1115.1 * AADApplication