From 734c9bd91fddb6de693b2b86285bd0cd4275236a Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Fri, 9 Sep 2022 10:52:46 -0700 Subject: [PATCH] Fixes for ADRoleSetting Export --- CHANGELOG.md | 5 +++++ .../MSFT_AADRoleSetting/MSFT_AADRoleSetting.psm1 | 2 +- Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1 | 11 ++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cb1965160..22b5c574ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change log for Microsoft365DSC +# UNRELEASED + +* AADRoleSetting + * Fixed an issue where the export wasn't properly passing credential to the Get function. + # 1.22.907.1 * EXODistributionGroup diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleSetting/MSFT_AADRoleSetting.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleSetting/MSFT_AADRoleSetting.psm1 index 4fdf0b4c5a..809f9ec600 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleSetting/MSFT_AADRoleSetting.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleSetting/MSFT_AADRoleSetting.psm1 @@ -190,7 +190,6 @@ function Get-TargetResource -InboundParameters $PSBoundParameters ` -ProfileName 'beta' - Select-MgProfile -Name 'beta' $MaximumFunctionCount = 32000 Write-Verbose -Message "Getting configuration of Role" @@ -1254,6 +1253,7 @@ function Export-TargetResource ApplicationId = $ApplicationId TenantId = $TenantId CertificateThumbprint = $CertificateThumbprint + Credential = $Credential } $Results = Get-TargetResource @Params $Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode ` diff --git a/Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1 index 401cc508b5..88e934f4d5 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1 @@ -783,15 +783,16 @@ function Get-M365DSCResourcesByWorkloads $Mode = 'Default' ) - Write-Host "Finding all resources for workload {$Workload} and Mode {$Mode}" -ForegroundColor Gray - $modules = Get-ChildItem -Path ($PSScriptRoot + "\..\DSCResources\") -Recurse -Filter '*.psm1' $Components = @() - foreach ($resource in $modules) + foreach ($Workload in $Workloads) { - $ResourceName = $resource.Name -replace "MSFT_", "" -replace ".psm1", "" - foreach ($Workload in $Workloads) + Write-Host "Finding all resources for workload {$Workload} and Mode {$Mode}" -ForegroundColor Gray + + foreach ($resource in $modules) { + $ResourceName = $resource.Name -replace "MSFT_", "" -replace ".psm1", "" + if ($ResourceName.StartsWith($Workload, 'CurrentCultureIgnoreCase') -and ($Mode -eq "Full" -or ` ($Mode -eq "Default" -and -not $Global:FullComponents.Contains($ResourceName)) -or `