Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

[SCSensitivityLabel] Idempotence issue with advanced settings

Open 1Dimitri opened this issue 8 months ago • 1 comments

Description of the issue

I've created manually a sensitivity label in a tenant. I'm trying to recreate the same label in an other tenant. The Set-TargetResource fails on the recreation of the AdvancedSettings part, because of comversion issue between JSON and expected parameter.

Microsoft 365 DSC Version

1.26.218.1

Which workloads are affected

Security & Compliance Center

The DSC configuration

param (
)

Configuration M365TenantConfig
{
    param (
    )

    $OrganizationName = $ConfigurationData.NonNodeData.OrganizationName

    Import-DscResource -ModuleName 'Microsoft365DSC' 

    Node localhost
    {


        SCSensitivityLabel "SCSensitivityLabel-1-Secret"
        {
            AdvancedSettings                               = @(
                MSFT_SCLabelSetting{
                    Key = "color"
                    Value = "#3A96DD"
                }
                MSFT_SCLabelSetting{
                    Key = "isparent"
                    Value = "False"
                }
            );
            ApplicationId                                  = $ConfigurationData.NonNodeData.ApplicationId;
            ApplyWaterMarkingFontColor                     = "#000000";
            ApplyWaterMarkingFontSize                      = "13";
            ApplyWaterMarkingLayout                        = "Diagonal";
            ApplyWaterMarkingText                          = "SECRET";
            CertificateThumbprint                          = $ConfigurationData.NonNodeData.CertificateThumbprint;
            Comment                                        = "";
            ContentType                                    = @("Teamwork","File","Email","Site","UnifiedGroup");
            DisplayName                                    = "Secret";
            EncryptionDoNotForward                         = $True;
            EncryptionEnabled                              = $True;
            EncryptionEncryptOnly                          = $False;
            EncryptionPromptUser                           = $True;
            EncryptionProtectionType                       = "userdefined";
            Ensure                                         = "Present";
            LocaleSettings                                 = @(
                MSFT_SCLabelLocaleSettings{
                    LabelSettings = @(
                        MSFT_SCLabelSetting{
                            Key = "default"
                            Value = "Secret"
                        }
                    )
                    localeKey = "displayName"
                }
                MSFT_SCLabelLocaleSettings{
                    LabelSettings = @(
                        MSFT_SCLabelSetting{
                            Key = "default"
                            Value = "Access strictly limited to named individuals; disclosure could cause severe harm to the company or its partners."
                        }
                    )
                    localeKey = "tooltip"
                }
            );
            Name                                           = "1-Secret";
            ParentId                                       = "XXXX";
            Priority                                       = 21;
            SiteAndGroupExternalSharingControlType         = "Disabled";
            SiteAndGroupProtectionAllowAccessToGuestUsers  = $False;
            SiteAndGroupProtectionAllowEmailFromGuestUsers = $False;
            SiteAndGroupProtectionAllowFullAccess          = $False;
            SiteAndGroupProtectionAllowLimitedAccess       = $False;
            SiteAndGroupProtectionBlockAccess              = $True;
            SiteAndGroupProtectionEnabled                  = $True;
            SiteAndGroupProtectionPrivacy                  = "private";
            TenantId                                       = $OrganizationName;
            Tooltip                                        = "Access strictly limited to named individuals; disclosure could cause severe harm to the company or its partners.";
        }

 
  
    }
}

M365TenantConfig -ConfigurationData .\ConfigurationData.psd1

Verbose logs showing the problem

PowerShell DSC resource MSFT_SCSensitivityLabel  failed to execute Set-TargetResource functionality with error
message: Cannot process argument transformation on parameter 'AdvancedSettings'. Cannot convert value "{
  "color": "#3A96DD",
  "isparent": "False"
}" to type "Microsoft.Office.CompliancePolicy.Tasks.PswsHashtable". Error: "Object of type
'Newtonsoft.Json.Linq.JObject' cannot be converted to type
'Microsoft.Office.CompliancePolicy.Tasks.PswsHashtable'."
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : localhost

Environment Information + PowerShell Version

OsName               : Microsoft Windows Server 2022 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 20348.1.amd64fre.fe_release.210507-1500
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PSVersion                      5.1.20348.4294
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.20348.4294
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

1Dimitri avatar Mar 16 '26 09:03 1Dimitri

Note: I would bet that [SCLabelPolicy] exhibits the same behavior due to the export output.

1Dimitri avatar Mar 17 '26 08:03 1Dimitri