MSFT_SCSensitivityLabel - Exception Calling "IndexOf" with "2"
Details of the scenario you tried and the problem that is occurring
Error : Exception calling "IndexOf" with "2" argument(s): "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: startIndex"
I'm trying to export our sensitivity labels so I can use them in new tenants without creating them manually. but when exporting as global admin i'm still getting the above error
Verbose logs showing the problem
Below is the only thing i'm getting in VSCode/Windows Terminal |---[1/6] OpenbaarVERBOSE: Attempting connection to {SecurityComplianceCenter} with: VERBOSE: Name Value
Credential System.Management.Automation.PSCredential
Name Openbaar
VERBOSE: Dependencies were already successfully validated. VERBOSE: Credential was specified. Connecting via User Principal VERBOSE: Dependencies were already successfully validated. ❌
eventviewer XML logs
Logboeknaam: M365DSC
Bron: MSFT_SCSensitivityLabel
Datum: 6-12-2022 09:17:31
Gebeurtenis-id:1
Taakcategorie: (1)
Niveau: Fout
Trefwoorden: Klassiek
Gebruiker: n.v.t.
Computer: LAPTOP
Beschrijving:
Exception calling "IndexOf" with "2" argument(s): "De index valt buiten het bereik. Deze mag niet negatief zijn en moet kleiner zijn dan de grootte van de verzameling.
Parameternaam: startIndex"
Gebeurtenis-XML:
Suggested solution to the issue
The DSC configuration that is used to reproduce the issue (as detailed as possible)
$cred = get-credential Export-M365DSCConfiguration -Components @("SCSensitivityLabel") -Verbose -Debug -Credential $cred
The operating system the target node is running
OsName : Microsoft Windows 10 Enterprise OsOperatingSystemSKU : EnterpriseEdition OsArchitecture : 64 bits WindowsVersion : 2009 WindowsBuildLabEx : 19041.1.amd64fre.vb_release.191206-1406 OsLanguage : nl-NL OsMuiLanguages : {nl-NL}
Version of the DSC module that was used ('dev' if using current dev branch)
1.22.1130.1
I cannot reproduce this issue in my lab. Maybe it is related to your custom labels. Can you please post the value of the Settings attribute of the first label (I think it is 'Openbaar')? (Get-Label "Openbaar" -IncludeDetailedLabelActions $true).Settings
This is the outcome :
[isparent, False] [contenttype, File, Email, Site, UnifiedGroup] [tooltip, Informatie die voor iedereen (burgers, bedrijven, instellingen) toegankelijk is.
De gegevens zijn niet vertrouwelijk, maar de correctheid (data-integriteit) van dergelijke gegevens is vaak wel van groot belang en ook is het belangrijk dat de informatie voor een breed publiek beschikbaar is.
Merking
- Online jaaroverzicht;
- Corporate films;
- Locatiegegevens;
- Televisie-uitzendingen;
- Persberichten;
- Open data.] [displayname, Openbaar] [color, #3A96DD]
Most of the tekst is in Dutch though
Thx. That is a bit strange. Just to share my thoughts: You are getting an error regarding indexof. The only indexof in the code of the SensitivityLabel resource is in line 1067: $startPos = $settingString.IndexOf(',', 0) + 1 With this we are trying to separate key and value for each setting of the Settings attribute. So, I thought about something special in your label configuration, but the code is working for each of your settings if I try it manually. Need to investigate this, but it is a bit hard without being able to reproduce the issue.
I am able to provide the script we used to import and export them without M365DSC and labels if that makes it easier.
Let´s give it a try. Can you share it here or do you want to share it private?
I've adjusted 2 things in this upload, the creator and modified by has been changed to "Creator" and i've changed the customer onmicrosoft reference in the document to Customer.onmicrosoft.com.
@hvdbrink I configured my tenant with the script you provided and after that, I could repro the issue. After some debugging I figured out that the error does not come from M365 DSC itself, but from the ReverseDSC module used by M365 DSC. The function Convert-DSCStringParamToVariable is throwing this error. It is caused by the string ";\r" in the value of the tooltip in the LocaleSettings of your Openbaar label. In my test it was enough to remove the ; before the \r to make the export work. Can you please test to confirm this?
I've tested it and can confirm after removing the ; from the tooltips I can export the "Openbaar" label. So the issues is resolved for our end.