-
Notifications
You must be signed in to change notification settings - Fork 610
Description
Description of the issue
Issue
SPOSharingSettings reports false drift when Get-TargetResource encounters intermittent connection errors but fails to handle them properly, returning Ensure = "Absent" instead of failing cleanly.
Error Details:
Error retrieving data:
{ Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. }
at Get-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.910.2\DscResources\MSFT_SPOSharingSettings\MSFT_SPOSharingSettings.psm1: line 178
at Test-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.910.2\DscResources\MSFT_SPOSharingSettings\MSFT_SPOSharingSettings.psm1: line 694
Configuration Drift Event:
<ConfigurationDrift Source="MSFT_SPOSharingSettings" TenantId="contoso.onmicrosoft.com">
<ParametersNotInDesiredState>
<Param Name="Ensure">
<CurrentValue>Absent</CurrentValue>
<DesiredValue>Present</DesiredValue>
</Param>
</ParametersNotInDesiredState>
</ConfigurationDrift>Root Cause
The centralized Test-M365DSCTargetResource function contains unprotected calls to individual resource Get-TargetResource functions, causing systematic false drift detection across all resources that utilize this shared function. When any resource experiences connection errors or API failures, the function fails to distinguish between legitimate configuration drift and retrieval failures, triggering unnecessary remediation cycles that can affect properly configured resources.
$CurrentValues = & MSFT_$ResourceName\Get-TargetResource @DesiredValuesImpact
- False drift alerts when intermittent connection issues occur
- Unnecessary remediation attempts on properly configured resources
- Cannot distinguish legitimate drift from retrieval failures
Solution
- Protect the
Get-TargetResourcecall inTest-M365DSCTargetResource - Return an error instead of false drift when current state retrieval fails
Microsoft 365 DSC Version
v1.25.910.2 (and later)
Which workloads are affected
SharePoint Online