Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

DSCParser chokes on hyphens in Email Headers

Open FlattusBlastus opened this issue 7 months ago • 13 comments

Description of the issue

Cant create a report

Microsoft 365 DSC Version

PROD / Latest

Which workloads are affected

Security & Compliance Center

The DSC configuration

Error parsing configuration: At line:226 char:54
+             SetHeader                           = @{X-P...
+                                                      ~
Missing '=' operator after key in hash literal.
At C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.17\Modules\DSCParser.psm1:472 char:9
+         throw "$($errorPrefix)Error parsing configuration: $parseErro

Verbose logs showing the problem


Environment Information + PowerShell Version


FlattusBlastus avatar Jun 02 '25 21:06 FlattusBlastus

@FlattusBlastus Can you share a bit more of your configuration for which you want to create the report? Especially the resource where the error occurs is of interest to us.

FabienTschanz avatar Jun 03 '25 17:06 FabienTschanz

Not sure how to share more config. M365DSC is loaded on my work laptop running the PROD latest updates EXCEPT EOM 3.71 because 3.7.2 and above is busted.

When a rule in the web ui for Set headers is entered its HeaderName:HeaderValue. The script returns SetHeader =@{X-restofname = "VALUE"}

Hence the error shown above makes more sense.

FlattusBlastus avatar Jun 06 '25 21:06 FlattusBlastus

Can you copy/paste the source file for which you want to generate the report? Or at least tell us the affected resource name? I don‘t know Exchange as well as the inside of my pocket, so a bit more information about the cirumstances around the issue would be really helpful.

E.g. the .ps1 from the config, a screenshot where the SetHeader property is set, or the command to generate the export (affected resources). Thank you.

FabienTschanz avatar Jun 07 '25 22:06 FabienTschanz

Can you guys do a Premier support ticket?

FlattusBlastus avatar Jun 09 '25 15:06 FlattusBlastus

M365DSC is not under coverage of the Premier support as far as I am aware of. It's either here with an issue or help yourself. Also, most of the work here is done by volunteers just like me, when the maintainers don't have enough time.

FabienTschanz avatar Jun 10 '25 14:06 FabienTschanz

I'll see if I can meet with my TAM (cant remember the current name for that) and maybe they can reach out.

FlattusBlastus avatar Jun 11 '25 20:06 FlattusBlastus

I think I found the problem: The export function for SetHeader produces @{ and not @("

FlattusBlastus avatar Jun 11 '25 21:06 FlattusBlastus

@FlattusBlastus Can you confirm that SetHeader in your configuration is part of the SCDLPComplianceRule? Would have liked to have this information a bit earlier, then I can help you better than always asking for more information 😅 Can you still share this specific DLP rule (be it in an anonymized way if you want to) with us? Then we can check it with our own tests. Thank you.

I'll take a look at it tomorrow, but it seems to be what you're describing. SetHeader is supposed to be a string array, but the little bit you shared indicates that it's another type of object.

FabienTschanz avatar Jun 11 '25 22:06 FabienTschanz

Output of M365TenantConfig.ps1 Broken - Stops creation of Excel report: SetHeader = @{X-EXC = "Excl"; }; I fixed the entries manually and the report completes: SetHeader = @("X-EXC = Excl");

FlattusBlastus avatar Jun 20 '25 19:06 FlattusBlastus

Yes it is in the SCDLPComplianceRule. The error output is: Error parsing configuration: At line:2349 char:54

  •         SetHeader                           = @{X-EXC = "Excl ...
    
  •                                                  ~
    

Missing '=' operator after key in hash literal. At C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.17\Modules\DSCParser.psm1:472 char:9

  •     throw "$($errorPrefix)Error parsing configuration: $parseErro ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (Error parsing c...n hash literal.:String) [], RuntimeException
    • FullyQualifiedErrorId : Error parsing configuration: At line:2349 char:54
  •         SetHeader                           = @{X-EXC = "Excl ...
    
  •                                                  ~
    

Missing '=' operator after key in hash literal.

FlattusBlastus avatar Jun 20 '25 19:06 FlattusBlastus

In the UI with SetHeader it uses a colon for separation instead of = if that helps any. Whatever is formatting the output is doing it incorrectly.

FlattusBlastus avatar Jun 20 '25 19:06 FlattusBlastus

Sorry - I can't send youM365TenantConfig.ps1 this way. Have Nik reach out to me on teams or contact [email protected] to get in contact with me. Charles Babcock.

FlattusBlastus avatar Jun 20 '25 19:06 FlattusBlastus

@FlattusBlastus No worries, I have the information that's required. PR is open.

FabienTschanz avatar Jun 22 '25 00:06 FabienTschanz