-
Notifications
You must be signed in to change notification settings - Fork 532
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
Comments
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.
@dannyKBjj I think that Do you have an example file to take a look at? |
Hi, sorry an example of what? A DSC export where the quotes are escaped?
I've attached a policy export (.txt format so I can send) I was having the
problem with.
Get-M365DSCExportContentForResource should do the conversion and escape
the quotes with a backtick only if they are inside of another string
Yes, that seems to be case. Except it isn't escaping with a backtick, it is
replacing and because the string is exported inside single quotes the
escape character wouldn't be needed anyway? Because of the way Get-
M365DSCExportContentForResource exports the string, the compiled mof will
evaluate as false against the policy it was exported from (because it is
looking for ` in the string and not "). Replacing ` with " within the ps1
and recompiling the mof file will fix it.
Admittedly I saw the issue creating
my IntuneMobileAppConfigurationPolicyIOS custom resource, but I assumed
that can't be the only policy type where quotes are potentially found
within string values? I assume it is a wider issue that could occur with
some other policies?
On Fri, Nov 15, 2024 at 1:05 PM FabienTschanz ***@***.***> wrote:
@dannyKBjj <https://github.com/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?
—
Reply to this email directly, view it on GitHub
<#5396 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BMQXRODH3AWEQZQQP5SXBFT2AXWS5AVCNFSM6AAAAABRWWQKKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZYG43TAMBTGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
# Generated with Microsoft365DSC version 1.24.1016.1
# For additional information on how to use Microsoft365DSC, please visit https://aka.ms/M365DSC
param (
)
Configuration M365TenantConfig
{
param (
)
$OrganizationName = $ConfigurationData.NonNodeData.OrganizationName
Import-DscResource -ModuleName 'Microsoft365DSC' -ModuleVersion '1.24.1016.1'
Node localhost
{
IntuneMobileAppConfigurationPolicyIOS "IntuneMobileAppConfigurationPolicyIOS-ACP_Edge_MDM_IOS"
{
ApplicationId = $ConfigurationData.NonNodeData.ApplicationId;
Assignments = @(
MSFT_DeviceManagementConfigurationPolicyAssignments{
deviceAndAppManagementAssignmentFilterType = 'none'
groupDisplayName = 'GRP_Intune_iPad_Branch_KIOSK_WPB_HK_POC'
dataType = '#microsoft.graph.exclusionGroupAssignmentTarget'
groupId = '2ea86bed-bf3e-48d7-923a-17de3a933fe2'
}
MSFT_DeviceManagementConfigurationPolicyAssignments{
deviceAndAppManagementAssignmentFilterType = 'none'
groupDisplayName = 'GRP_Intune_App_MSTunnel_MDM_Prod_Pilot'
dataType = '#microsoft.graph.groupAssignmentTarget'
groupId = '9e9e550e-ada6-4ff7-b81a-5826a6939158'
}
MSFT_DeviceManagementConfigurationPolicyAssignments{
deviceAndAppManagementAssignmentFilterType = 'none'
groupDisplayName = 'GRP_Intune_App_MSTunnel_Edge_Troubleshooting'
dataType = '#microsoft.graph.exclusionGroupAssignmentTarget'
groupId = 'accc9f6d-14b0-4e1b-81ba-bed35d4282b2'
}
MSFT_DeviceManagementConfigurationPolicyAssignments{
deviceAndAppManagementAssignmentFilterType = 'none'
groupDisplayName = 'GRP_Intune_App_MSEdge'
dataType = '#microsoft.graph.groupAssignmentTarget'
groupId = 'b69f3898-96e7-4473-a282-35fcb6f3d1ce'
}
);
CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint;
Description = "";
DisplayName = "ACP_Edge_MDM_IOS";
Ensure = "Present";
Id = "70c13254-b692-4eb2-ba77-633d349c7d0e";
settings = @(
MSFT_appConfigurationSettingItem{
appConfigKey = 'IntuneMAMAllowedAccountsOnly'
appConfigKeyType = 'stringType'
appConfigKeyValue = 'Enabled'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'IntuneMAMUPN'
appConfigKeyType = 'stringType'
appConfigKeyValue = '{{userprincipalname}}'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'SearchSuggestEnabled'
appConfigKeyType = 'booleanType'
appConfigKeyValue = 'true'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'DefaultSearchProviderEnabled'
appConfigKeyType = 'booleanType'
appConfigKeyValue = 'true'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'DefaultSearchProviderName'
appConfigKeyType = 'stringType'
appConfigKeyValue = 'Ecosia'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'DefaultSearchProviderSearchURL'
appConfigKeyType = 'stringType'
appConfigKeyValue = 'https://www.ecosia.org/search?q={searchTerms}'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'TranslateEnabled'
appConfigKeyType = 'booleanType'
appConfigKeyValue = 'false'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'URLBlocklist'
appConfigKeyType = 'stringType'
appConfigKeyValue = '[`edge://flags`,`edge://inspect`,`edge://optimization-guide-internals`,`edge://password-manager-internals`]'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'DefaultPopupsSetting'
appConfigKeyType = 'integerType'
appConfigKeyValue = '2'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'AuthSchemes'
appConfigKeyType = 'stringType'
appConfigKeyValue = 'digest,ntlm,negotiate'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'EdgeDisabledFeatures'
appConfigKeyType = 'stringType'
appConfigKeyValue = 'inprivate'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'PasswordManagerEnabled'
appConfigKeyType = 'booleanType'
appConfigKeyValue = 'false'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'EdgeDisableShareUsageData'
appConfigKeyType = 'booleanType'
appConfigKeyValue = 'true'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'EdgeSyncDisabled'
appConfigKeyType = 'booleanType'
appConfigKeyValue = 'true'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'EdgeNewTabPageCustomURL'
appConfigKeyType = 'stringType'
appConfigKeyValue = 'https://hsbc.sharepoint.com/sites/workplace/SitePages/Start.aspx'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'EdgeNetworkStackPref'
appConfigKeyType = 'integerType'
appConfigKeyValue = '1'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'EdgeImportPasswordsDisabled'
appConfigKeyType = 'booleanType'
appConfigKeyValue = 'true'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'EdgeMyApps'
appConfigKeyType = 'booleanType'
appConfigKeyValue = 'false'
}
MSFT_appConfigurationSettingItem{
appConfigKey = 'ManagedFavorites'
appConfigKeyType = 'stringType'
appConfigKeyValue = '[{ `toplevel_name`: `My managed favorites folder` }, { `name`: `Google`, `url`: `google.com` }, { `name`: `Yahoo`, `url`: `yahoo.com` }]'
}
);
targetedMobileApps = @("daaabd1b-b374-4b14-83e3-ab87d2668f8a");
TenantId = $OrganizationName;
}
}
}
M365TenantConfig -ConfigurationData .\ConfigurationData.psd1
|
@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. Am I right that the |
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? |
I'll take a look at it later, stay tuned. |
@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. |
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. |
@dannyKBjj I found the issue, currently working on it. Removing characters and updating some position counters need to go hand in hand for success. |
@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. |
hi, downloaded the new file and re-exported from my tenant. This time it worked perfectly. Thanks. |
@dannyKBjj Alright, thank you for the feedback. I don't know when it will be available, we will see. |
Thanks, I can use the version I downloaded from you in the mean time. |
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
The text was updated successfully, but these errors were encountered: