Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

Export-M365DSCConfiguration: Workload EXO - Organization cannot be null

Open fvancaelenbergnbb opened this issue 1 year ago • 6 comments

Description of the issue

When i try to do an Export-M365DSCConfiguration for the workload of EXO (ExchangeOnline), I get the following error for all components. I tried it with PS5.1 and PS7... with managed identities AND app registration

[2025-02-21 11:25:03] [INFO] ------------------------------[1/101 - Export EXOAcceptedDomain]------------------------------ [2025-02-21 11:25:03] [INFO] Trying to pull EXOAcceptedDomain. Exporting Microsoft 365 configuration for Components: EXOAcceptedDomain There is a newer version of the 'Microsoft365DSC' module available on the gallery. To update the module and it's dependencies, run the following command: Update-M365DSCModule

Authentication methods specified:

  • Managed Identity

Connecting to {ExchangeOnline}...❌ Partial Export file was saved at: C:\Users\ADMIN~4.VAN\AppData\Local\Temp\18\a43126b2-fb40-4389-8c1c-66a9adc5b61c.partial.ps1 [2025-02-21 11:25:08] [WARN] Exception occured. [2025-02-21 11:25:08] [ERROR] Value cannot be null. Parameter name: Organization cannot be null for Managed Identity based connections.

Transcript: [2025-02-21 11:25:03] [INFO] ------------------------------[1/101 - Export EXOAcceptedDomain]------------------------------ [2025-02-21 11:25:03] [INFO] Trying to pull EXOAcceptedDomain. PS>TerminatingError(Disconnect-MgGraph): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: No application to sign out from." Exporting Microsoft 365 configuration for Components: EXOAcceptedDomain There is a newer version of the 'Microsoft365DSC' module available on the gallery. To update the module and it's dependencies, run the following command: Update-M365DSCModule

Authentication methods specified:

  • Managed Identity

Connecting to {ExchangeOnline}... INFO: Disconnected successfully ! PS>TerminatingError(Get-ConnectionContext): "Value cannot be null. Parameter name: Organization cannot be null for Managed Identity based connections." PS>TerminatingError(): "Value cannot be null. Parameter name: Organization cannot be null for Managed Identity based connections."

TerminatingError(): "Value cannot be null. Parameter name: Organization cannot be null for Managed Identity based connections." TerminatingError(): "Value cannot be null. Parameter name: Organization cannot be null for Managed Identity based connections." ❌ Partial Export file was saved at: C:\Users\ADMIN~4.VAN\AppData\Local\Temp\18\a43126b2-fb40-4389-8c1c-66a9adc5b61c.partial.ps1 PS>TerminatingError(): "Value cannot be null. Parameter name: Organization cannot be null for Managed Identity based connections." TerminatingError(): "Value cannot be null. Parameter name: Organization cannot be null for Managed Identity based connections." [2025-02-21 11:25:08] [WARN] Exception occured. [2025-02-21 11:25:08] [ERROR] Value cannot be null. Parameter name: Organization cannot be null for Managed Identity based connections.

Microsoft 365 DSC Version

1.25.212.2

Which workloads are affected

Exchange Online

The DSC configuration


Verbose logs showing the problem


Environment Information + PowerShell Version

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


PSVersion                      7.4.6
PSEdition                      Core
GitCommitId                    7.4.6
OS                             Microsoft Windows 10.0.20348
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

fvancaelenbergnbb avatar Feb 21 '25 10:02 fvancaelenbergnbb

@Franky709 Can you please provide the command line you used when exporting? For example, using app registration with a client certificate, the following works for me:

$clientId = "XXX"
$tenantIdName = "xxx.onmicrosoft.com"
$certThumbPrintEXO = "XXX"
Export-M365DSCConfiguration -Components @("EXOAddressList") -Path D:\testbed -ApplicationId $clientId -TenantId $tenantIdName -CertificateThumbprint $certThumbprintEXO -Verbose

Did you specify -TenantId? If no, please use your company.onmicrosoft.com domain name. If yes, does it work if you use Credentials to export?

FabienTschanz avatar Feb 21 '25 17:02 FabienTschanz

@Franky709 Can you please provide the command line you used when exporting? For example, using app registration with a client certificate, the following works for me:

$clientId = "XXX" $tenantIdName = "xxx.onmicrosoft.com" $certThumbPrintEXO = "XXX" Export-M365DSCConfiguration -Components @("EXOAddressList") -Path D:\testbed -ApplicationId $clientId -TenantId $tenantIdName -CertificateThumbprint $certThumbprintEXO -Verbose Did you specify -TenantId? If no, please use your company.onmicrosoft.com domain name. If yes, does it work if you use Credentials to export?

@FabienTschanz

I've tried with AppReg (certificate + thumbprint) AND Managed Identity. Indeed i'm using .onmicrosoft.com for tenantIdName. Even tried PS5.1 and 7. Which version are you using?

Export-M365DSCConfiguration -Components @("$comp") -ManagedIdentity -TenantId $tenantName -Path $exportPath -Verbose;

Export-M365DSCConfiguration -Components @("$comp") -TenantId $tenantName -ApplicationId $appId -CertificateThumbprint $thumbprint -Path $exportPath -Verbose;

fvancaelenbergnbb avatar Feb 22 '25 12:02 fvancaelenbergnbb

I'm using PS5.1, but it also works on PS 7.4.6 for me as well. No issues there. Can you please add the -Verbose switch to the command and post the output of the entire output? It will be quite long, so you could also upload it as a .txt file if you want to.

FabienTschanz avatar Feb 24 '25 16:02 FabienTschanz

In the linked .txt file is the transscript with verbose for the component: EXOAcceptedDomain, as an example

test_manual_EXO_2025.02.25-12.08.txt

fvancaelenbergnbb avatar Feb 25 '25 11:02 fvancaelenbergnbb

Okay, so I just executed the same command as you with -ManagedIdentity, and it's also failing for me. This is most likely because you are not executing it e.g. on an Automation Runner with a System-assigned managed identity. That would explain why you get this error (because it fails to use a managed identity since there doesn't exist any on your platform).

What's the transcript for certificate exports? Is the certificate you're using one with SHA1 or SHA256? I had to switch to SHA1 for it to work when generating, otherwise I'd get an exception during connect.

FabienTschanz avatar Feb 27 '25 20:02 FabienTschanz

Closing for now - If it still occurs, let us know.

FabienTschanz avatar Jun 19 '25 06:06 FabienTschanz