Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export-M365DSCConfiguration: Workload EXO - Organization cannot be null #5823

Open
Franky709 opened this issue Feb 21, 2025 · 5 comments
Open

Comments

@Franky709
Copy link

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
@FabienTschanz
Copy link
Collaborator

@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?

@Franky709
Copy link
Author

@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;

@FabienTschanz
Copy link
Collaborator

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.

@Franky709
Copy link
Author

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

@FabienTschanz
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants