Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

EXODynamicDistributionGroup - Unable to export due to null filter

Open Dekor86 opened this issue 1 month ago • 1 comments

Description of the issue

When running an export scoped to just the "EXODynamicDistributionGroup" component, it fails due to a filter being provided a $null value.

Reviewing the part04.psm1 referenced in the error I can see line 2708 has this:

[array]$getValue = Get-DynamicDistributionGroup -Filter $this.Filter -ErrorAction Stop

I suspect that the $this.Filter value is null which is why EXO API responds with the error. Not been able to identify where this parameter originates from.

This can be reproduced by running following against exchange online powershell:

get-dynamicdistributiongroup -filter ""

Response:

Get-DynamicDistributionGroup: Cannot validate argument on parameter 'Filter'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

Recommend that if the $this.filter value is null, the -filter switch is omitted from the command.

Microsoft 365 DSC Version

2.26.1028.1

Which workloads are affected

Exchange Online

The DSC configuration

Export-M365DSCConfiguration `
        -ApplicationId "$(appID)" `
        -TenantId "$(tenantDomain)" `
        -CertificateThumbprint "$(certificateThumbprint)" `
        -Components @('EXODynamicDistributionGroup') `
        -Mode Full `
        -Validate `
        -Verbose `
        -Path $snapshotPath `
        -FileName "devTenantSnapshot.ps1" `
        -ConfigurationName "DevTenantSnapshot" `
        -WithStatistics

Verbose logs showing the problem

[2026/11/03 12:53:22]
{InvalidData}
System.Management.Automation.ParameterBindingValidationException: Cannot validate argument on parameter 'Filter'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
 ---> System.Management.Automation.ValidationMetadataException: The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
   at System.Management.Automation.ValidateNotNullOrAttributeBase.Validate(Object arguments, EngineIntrinsics engineIntrinsics)
   at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
   --- End of inner exception stack trace ---
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
"Error during Export:"
at Export, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\2.26.1028.1\Classes\Part04.psm1: line 2708
at Invoke-M365DSCResourceMethod, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\2.26.1028.1\Classes\_Shared.psm1: line 1609
at <ScriptBlock>, <No file>: line 136
at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\2.26.1028.1\Modules\M365DSCReverse.psm1: line 1071
at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\2.26.1028.1\Modules\M365DSCExportUtil.psm1: line 538
at <ScriptBlock>, D:\a\_temp\2fb6320b-a4bd-48aa-9738-486fa8abefc2.ps1: line 22
at <ScriptBlock>, <No file>: line 1

Environment Information + PowerShell Version

PowerShell 7, running on Azure Pipelines using Azure PowerShell task  2.281.0

Dekor86 avatar Nov 03 '26 13:11 Dekor86

@Dekor86 Don't have any dynamic groups to test this but you can try my patch on #7587 which should do the trick

ricmestre avatar Nov 03 '26 14:11 ricmestre