microsoft / Microsoft365DSC

Manages, configures, extracts and monitors Microsoft 365 tenant configurations
https://aka.ms/M365DSC
MIT License
1.61k stars 500 forks source link

export-dsc problem handling quotes in string #5396

Open dannyKBjj opened 2 days ago

dannyKBjj commented 2 days ago

Description of the issue

Am creating a custom DSC resource for #microsoft.graph.iosMobileAppConfiguration , for the most part it works fine, but some of the settings for some policies contain quotes in the string. For example and iOS Edge AI policy

URLBlocklist stringtype ["edge://flags","edge://inspect","edge://optimization-guide-internals","edge://password-manager-internals"]

is exported to the M365TenantConfig.ps1 with back-ticks instead of quotes. i.e. [edge://flags,edge://inspect,edge://optimization-guide-internals,edge://password-manager-internals] . The .mof will compile fine, but then report 'false' when tested. Replacing ` with " in the .ps1 and recompiling the .mof fixes the issue. The data is retrieved correctly. Problem seems to be with either Get-M365DSCExportContentForResource or Convert-DSCStringParamToVariable. I'd assume it is a wider issue with handling quotes in strings.

Microsoft 365 DSC Version

1.24.1016.1

Which workloads are affected

other

The DSC configuration

Verbose logs showing the problem

Environment Information + PowerShell Version

FabienTschanz commented 14 hours ago

@dannyKBjj I think that Get-M365DSCExportContentForResource should do the conversion and escape the quotes with a backtick only if they are inside of another string. Otherwise, it should preserve the current state of it. That's how it's handled across all resources, also with some resources that I just developed it works fine.

Do you have an example file to take a look at?