diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ea6b11f8d..565d7823e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,8 @@ * M365DSCReport * Fix missing delimiter when called without the parameter. FIXES [#5634](https://github.com/microsoft/Microsoft365DSC/issues/5634) + * Add configuration validation to inform about comparisons against empty or invalid configurations. + FIXES [#5658](https://github.com/microsoft/Microsoft365DSC/issues/5658) * M365DSCTelemetryEngine * Report LCM details only if running as administrator. * M365DSCUtil diff --git a/Modules/Microsoft365DSC/Modules/M365DSCReport.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCReport.psm1 index b5008d6b73..839ed51456 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCReport.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCReport.psm1 @@ -2073,8 +2073,12 @@ function Initialize-M365DSCReporting $parsedContent = ConvertTo-DSCObject -Content $fileContent } - return $parsedContent + if ($null -eq $parsedContent) + { + Write-Warning -Message "No configuration found in $ConfigurationPath. Either the configuration was empty or the file was not a valid DSC configuration." + } + return $parsedContent } Export-ModuleMember -Function @(