diff --git a/CHANGELOG.md b/CHANGELOG.md index bace3d31c4..414eb1a599 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,9 @@ * SCRetentionComplianceRule * Fixed an Issue where properties weren't properly set at creation, causing drifts to be detected. FIXES [#2471](https://github.com/microsoft/Microsoft365DSC/issues/2471) +* SPOTenantCdnEnabled + * Fixed an issue where the export wasn't returning anything if the CDN was not enabled. + FIXES [#2466](https://github.com/microsoft/Microsoft365DSC/issues/2466) * SPOUserProfileProperty * Removed multi-threading to align with other resources. * Fixed an issue where we were contacting Microsoft Graph to retrieve users without authenticating to it. diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_SPOTenantCdnEnabled/MSFT_SPOTenantCdnEnabled.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_SPOTenantCdnEnabled/MSFT_SPOTenantCdnEnabled.psm1 index 1dfcf05865..31a1f40020 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_SPOTenantCdnEnabled/MSFT_SPOTenantCdnEnabled.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_SPOTenantCdnEnabled/MSFT_SPOTenantCdnEnabled.psm1 @@ -57,6 +57,9 @@ function Get-TargetResource $ConnectionMode = New-M365DSCConnection -Workload 'PNP' ` -InboundParameters $PSBoundParameters + $nullResult = $PSBoundParameters + $nullResult.Ensure = 'Absent' + #Ensure the proper dependencies are installed in the current environment. Confirm-M365DSCDependencies @@ -101,7 +104,7 @@ function Get-TargetResource throw $_ } - return @{} + return $nullResult } } @@ -355,19 +358,16 @@ function Export-TargetResource $Results = Get-TargetResource @Params Write-Host " |---[$i/2] $cType" -NoNewline - if ($Results.Enable -eq $True) - { - $Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode ` - -Results $Results - $currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName ` - -ConnectionMode $ConnectionMode ` - -ModulePath $PSScriptRoot ` - -Results $Results ` - -Credential $Credential - $dscContent += $currentDSCBlock - Save-M365DSCPartialExport -Content $currentDSCBlock ` - -FileName $Global:PartialExportFileName - } + $Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode ` + -Results $Results + $currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName ` + -ConnectionMode $ConnectionMode ` + -ModulePath $PSScriptRoot ` + -Results $Results ` + -Credential $Credential + $dscContent += $currentDSCBlock + Save-M365DSCPartialExport -Content $currentDSCBlock ` + -FileName $Global:PartialExportFileName $i++ Write-Host $Global:M365DSCEmojiGreenCheckmark }