microsoft/Microsoft365DSC

IntuneDeviceConfigurationDefenderForEndpointOnboardingPolicyWindows10: Error in catch block overwrites/hides original error?

commandcom opened this issue · 1 comments

Description of the issue

  • Run Test-DscConfiguration on mof/resource in title
    • Returns error: "Cannot bind argument to parameter 'BoundParameters' because it is null"
  • Test-DscConfiguration calls the Get-TargetResource function
    • The entire function is covered in a try/catch block
    • The catch block passes a variable named: $nullResult to the Clear-M365DSCAuthenticationParameter
    • Clear-M365DSCAuthenticationParameter does not accept nulls for the BoundParameters parameter:

image

  • What seems to be happening:
    • An error occurs before the $nullResult variable gets set
    • Catch block picks up the error and passes the uninitialized $nullResult to Clear-M365DSCAuthenticationParameter
    • The parameter validation in Clear-M365DSCAuthenticationParameter throws the error

image

image

  • In our scenario, the assumption is we're getting a permission error in the call to Graph, resulting in the "BoundParameters" error
  • I cannot step through the code to prove this is what is actually happening
  • But on paper, this seems like a plausible explanation as to the root cause
  • Happy to answer any questions you might have

Microsoft 365 DSC Version

1.24.424.1

Which workloads are affected

Intune

The DSC configuration

No response

Verbose logs showing the problem

No response

Environment Information + PowerShell Version

OsName               : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 1809
WindowsBuildLabEx    : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

Key   : PSVersion
Value : 5.1.17763.5933
Name  : PSVersion

Key   : PSEdition
Value : Desktop
Name  : PSEdition

Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name  : PSCompatibleVersions

Key   : BuildVersion
Value : 10.0.17763.5933
Name  : BuildVersion

Key   : CLRVersion
Value : 4.0.30319.42000
Name  : CLRVersion

Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion

Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion

Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion