Skip to content

Commit

Permalink
Merge pull request microsoft#3920 from MKlingner/features/AADRoleSett…
Browse files Browse the repository at this point in the history
…ing_Export_Filter

AADRoleSetting export with Filter and sort by DisplayName
  • Loading branch information
ykuijs authored Nov 28, 2023
2 parents 4a4380b + 2126864 commit cb586e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Change log for Microsoft365DSC

# UNRELEASED

* 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)
* DEPENDENCIES
* Updated Microsoft.Graph to version 2.10.0.
* Updated MSCloudLoginAssistant to version 1.1.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,7 @@ function Test-TargetResource
[Switch]
$ManagedIdentity
)
$Script:ExportMode = $false

#Ensure the proper dependencies are installed in the current environment.
Confirm-M365DSCDependencies
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit cb586e8

Please sign in to comment.