Skip to content

[SCSensitivityLabel]: Idempotence: Cannot recreate Label groups #6994

@1Dimitri

Description

@1Dimitri

Description of the issue

I have created a label group in a tenant with associated labels in a tenant.
I'm trying to recreate the group and those labels in another tenant.
I'm using the latest version of M365DSC since it fixes the AdvancedSettings creation issue previously experienced (#6973) it needs to create a group

The label group cannot be recreated as is.

  • First attempt complains that ContentType cannot be empty when running Start-DSCConfiguration , whereas the export of the group has put a ContentType=@() line.
  • Second attempt, when removing the ContentType line manages to create the object but as a regular label, not as a group
  • Usage of the New-Label PS CmdLet directly with proper advancedsettings hashtable creates the group as a group.

Microsoft 365 DSC Version

1.26.318.1

Which workloads are affected

Security & Compliance Center

The DSC configuration

# Generated with Microsoft365DSC version 1.26.318.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' 

    Node localhost
    {
               SCSensitivityLabel "SCSensitivityLabel-M365DSCLabels"
        {
            AdvancedSettings      = @(
                MSFT_SCLabelSetting{
                    Key = "color"
                    Value = "#3A96DD"
                }
                MSFT_SCLabelSetting{
                    Key = "isparent"
                    Value = "True"
                }
                MSFT_SCLabelSetting{
                    Key = "islabelgroup"
                    Value = "True"
                }
            );
            ApplicationId         = $ConfigurationData.NonNodeData.ApplicationId;
            CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint;
            Comment               = "See Data Classification PDF";
            # To reproduce first attempt, uncomment
            # ContentType           = @();
            DisplayName           = "M365DSCLabelgroup";
            Ensure                = "Present";
            LocaleSettings        = @(
                MSFT_SCLabelLocaleSettings{
                    LabelSettings = @(
                        MSFT_SCLabelSetting{
                            Key = "default"
                            Value = "M365DSCLabelgroup"
                        }
                    )
                    LocaleKey = "displayName"
                }
                MSFT_SCLabelLocaleSettings{
                    LabelSettings = @(
                        MSFT_SCLabelSetting{
                            Key = "default"
                            Value = "Predefined Labels at the Company Level. Refer to the documentation you have received to know more about their differences"
                        }
                    )
                    LocaleKey = "tooltip"
                }
            );
            Name                  = "M365DSCLabels";
            Priority              = 16;
            TenantId              = $OrganizationName;
            Tooltip               = "Predefined Labels at the Company Level. Refer to the documentation you have received to know more about their differences";
        }
    }
}

M365TenantConfig -ConfigurationData .\ConfigurationData.psd1

Verbose logs showing the problem

First attempt

PowerShell DSC resource MSFT_SCSensitivityLabel  failed to execute Set-TargetResource functionality with error
message: |Microsoft.Exchange.Management.UnifiedPolicy.InvalidMipLabelContentTypeException|The content type
'None' is invalid.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : localhost

Second Attempt

Creating Label {M365DSCLabels} with:
{
    "LocaleSettings":  [
                           "{\r\n    \"localeKey\":  \"displayName\",\r\n    \"Settings\":  [\r\n
      {\r\n                         \"Key\":  \"default\",\r\n                         \"Value\":
\"M365DSCLabelgroup\"\r\n                     }\r\n                 ]\r\n}",
                           "{\r\n    \"localeKey\":  \"tooltip\",\r\n    \"Settings\":  [\r\n
  {\r\n                         \"Key\":  \"default\",\r\n                         \"Value\":  \"Predefined
Labels at the Company Level. Refer to the documentation you have received to know more about their
differences\"\r\n                     }\r\n                 ]\r\n}"
                       ],
    "Tooltip":  "Predefined Labels at the Company Level. Refer to the documentation you have received to know
more about their differences",
    "Comment":  "See Data Classification PDF",
    "DisplayName":  "M365DSCLabelgroup",
    "AdvancedSettings":  {
                             "color":  "#3A96DD",
                             "isparent":  "True",
                             "islabelgroup":  "True"
                         },
    "Name":  "M365DSCLabels"
}

Powershell working command


New-Label -AdvancedSettings @{'isparent'='True';'islabelgroup'='True'} -Comment "See DataClassification PDF" -DisplayName "PSLabelsTest"  -Name "PSLabelsTest" -Tooltip "Predefined Labels at the Company Level. Refer to the documentation you have received"

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions