Powershell DSC error: OperationStopped: Serialized XML is nested too deeply. Line 1, position 3459

40 Views Asked by At

I created a very basic DscResource and it successfully running the Get method. For testing purposes I defined Test method like that:

[bool] Test() {
  return $true
}

but every time that I invoke this method running:

Invoke-DscResource ... -Method Test

the output is error:

OperationStopped: Serialized XML is nested too deeply. Line 1, position 3459.

but actually in Event viewer the operation completed successfully:

[
  {"time": "2024-02-06T13:03:11.076+02:00", "type": "verbose", "message": "[QUICK-DEV]: LCM:  [ Start  Test     ]  [[VmFirewall]DirectResourceAccess]  "},
  {"time": "2024-02-06T13:03:11.155+02:00", "type": "verbose", "message": "[QUICK-DEV]: LCM:  [ End    Test     ]  [[VmFirewall]DirectResourceAccess] True in 0.0790 seconds."},
  {"time": "2024-02-06T13:03:11.155+02:00", "type": "verbose", "message": "[QUICK-DEV]: LCM:  [ End    Set      ]    in  0.2200 seconds."}
]

Why this message Serialized XML is nested too deeply appear ? and what I can do about it ?

2

There are 2 best solutions below

0
Alex F On

It seems like a bug in Powershell... Everything working as expected if I use Windows Powershell but it fails with error if I user Powershell Core.... So strange...

0
PoshAJ On

I ran into this today, Windows PowerShell 5.1 ships with PSDesiredStateConfiguration v1.1, this mixed with the Windows PowerShell Compatibility feature means that PowerShell 7 will attempt to use the compatibility session. The error is due to the session attempting to serialize/deserialize the return values for the DSC resource.

The options are to

  • Update to PSDesiredStateConfiguration v2.0.
  • Use the WindowsPowerShellCompatibilityModuleDenyList setting in PowerShell configuration file.
  • Use the DisableImplicitWinCompat setting in PowerShell configuration file.