Issue when exporting O365OrgSettings and SCLabelPolicy / SCSensitivityLabel resources
Description of the issue
Exporting O365OrgSettings and SCLabelPolicy or SCSensitivityLabel resources does not work since version 1.25.115.1. There is an error on SCLabelPolicy and SCSensitivityLabel export. I have tried with different tenants and always get the below error. The issue was not there on the version that I was using before (1.24.1218.1). SCLabelPolicy or SCSensitivityLabel export works fine when you do not export O365OrgSettings.
Microsoft 365 DSC Version
1.25.115.1
Which workloads are affected
Security & Compliance Center
The DSC configuration
Export-M365DSCConfiguration -Components O365OrgSettings,SCLabelPolicy,SCSensitivityLabel
Verbose logs showing the problem
Console:
PS C:\Windows\system32> Export-M365DSCConfiguration -Components O365OrgSettings,SCLabelPolicy,SCSensitivityLabel
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
Exporting Microsoft 365 configuration for Components: O365OrgSettings, SCLabelPolicy, SCSensitivityLabel
Authentication methods specified:
- Credentials
Connecting to {ExchangeOnline}...✅
Connecting to {SecurityComplianceCenter}...✅
[1/3] Extracting [O365OrgSettings] using {Credentials}...✅
[2/3] Extracting [SCLabelPolicy] using {Credentials}...❌
Error Log created at {file://C:/Windows/system32/12048-M365DSC-ErrorLog.log}
[3/3] Extracting [SCSensitivityLabel] using {Credentials}...❌
Error Log created at {file://C:/Windows/system32/12048-M365DSC-ErrorLog.log}
⌛ Export took {96 seconds} for {1 instances}
Log file:
[2025/01/28 06:25:30]
{ObjectNotFound}
System.Management.Automation.CommandNotFoundException: The term 'Get-Label' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
"Error during Export:"
at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.122.2\DSCResources\MSFT_SCSensitivityLabel\MSFT_SCSensitivityLabel.psm1: line 1575
at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.122.2\Modules\M365DSCReverse.psm1: line 689
at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.122.2\Modules\M365DSCUtil.psm1: line 1512
at <ScriptBlock>, <No file>: line 1
[email protected]
TenantId: erfitcs01.onmicrosoft.com
Environment Information + PowerShell Version
For info it seems that the issue was introduced with version 1.25.108.1. It was still working fine with 1.24.1218.1.
Might be an issue with the new way of connecting they introduced in that version. Just using SCLabelPolicy, SCSensitivityLabel works just fine, it's going wrong when introducing another workload into the export. Atleast for me
In fact I can export SCLabelPolicy and SCSensitivityLabel with all other resources except O365OrgSettings. The issue is that the cmdlets from the Security and compliance module like "Get-Label" do not seem to be available anymore after exporting O365OrgSettings: System.Management.Automation.CommandNotFoundException: The term 'Get-Label' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again..
It's not the case when I do not export O365OrgSettings so I guess that it has something to do with that resource but I had a look at the code and cannot find anything that would disconnect the security and compliance module session.
Any update?
Issue is solved on the last version.