Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export-dsc problem handling quotes in string #5396

Closed
dannyKBjj opened this issue Nov 13, 2024 · 12 comments
Closed

export-dsc problem handling quotes in string #5396

dannyKBjj opened this issue Nov 13, 2024 · 12 comments

Comments

@dannyKBjj
Copy link
Contributor

dannyKBjj commented Nov 13, 2024

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

dannyKBjj added a commit to dannyKBjj/Microsoft365DSC that referenced this issue Nov 13, 2024
Module is affected by issue microsoft#5396. Replace ` with " in M365TenantConfig.ps1 is your configuration key values contain double quotes. Otherwise, it should work as expected.
@FabienTschanz
Copy link
Collaborator

@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?

@dannyKBjj
Copy link
Contributor Author

dannyKBjj commented Nov 16, 2024 via email

@FabienTschanz
Copy link
Collaborator

@dannyKBjj Your mail response looks pretty horrible here in GitHub 😅 Also I can't see the file you sent along, it's not being forwarded.
Normally, there shouldn't be quotes in another string. That aside, the parser normally is able to escape these quotes properly and not just replace them.

Am I right that the URLBlocklist property you mentioned in your issue description is from the IntuneMobileAppConfigurationPolicyIOS? Is it one of the MSFT_appConfigurationSettingItem elements?

@dannyKBjj
Copy link
Contributor Author

Your mail response looks pretty horrible here in GitHub
So it does! I'll reply directly here from now on.

Am I right that the URLBlocklist property you mentioned in your issue description is from the IntuneMobileAppConfigurationPolicyIOS? Is it one of the MSFT_appConfigurationSettingItem elements?

Yes that's correct. Is the problem with my custom Resource? If it is, I couldn't see it, but would love to know what I can do to fix it?

M365TenantConfig.txt

@FabienTschanz
Copy link
Collaborator

I'll take a look at it later, stay tuned.

@FabienTschanz
Copy link
Collaborator

@dannyKBjj I opened a PR that should address your issue. According to my testing, it does that as expected. Do you mind testing with the updated ReverseDSC file that is linked in the pull request? You can copy the entire file contents into C:\Program Files\WindowsPowerShell\Modules\ReverseDSC\2.0.0.22\ReverseDSC.Core.psm1, restart the PowerShell session, and try again.

@dannyKBjj
Copy link
Contributor Author

Hi, just tested. It is now creating the values correctly, but the output is still not valid unfortunately.

I've attached what get exported from my tenant. On line 112 it added

,"

for some strange reason? As soon as you remove that, it'll compile just fine.

exportedPolicy.txt

@FabienTschanz
Copy link
Collaborator

@dannyKBjj I found the issue, currently working on it. Removing characters and updating some position counters need to go hand in hand for success.

@FabienTschanz
Copy link
Collaborator

@dannyKBjj I just updated my PR with some very small changes, do you mind trying again? It should work now, I missed your case if another setting comes after one with quotes inside of the string value.

@dannyKBjj
Copy link
Contributor Author

hi, downloaded the new file and re-exported from my tenant. This time it worked perfectly. Thanks.

@FabienTschanz
Copy link
Collaborator

@dannyKBjj Alright, thank you for the feedback. I don't know when it will be available, we will see.

@dannyKBjj
Copy link
Contributor Author

Thanks, I can use the version I downloaded from you in the mean time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants