Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

Export-M365DSCConfiguration: Connecting to ExchangeOnline fails

Open nick-waterhouse opened this issue 7 months ago • 2 comments

Description of the issue

Running Export-M365DSCConfiguration errors out early, as it is unable to connect to ExchangeOnline. I have updated to the latest version Microsoft365DSC.

Microsoft 365 DSC Version

1.25.514.1

Which workloads are affected

Exchange Online

The DSC configuration


Verbose logs showing the problem

Method not found: 'Microsoft.Identity.Client.PublicClientApplicationBuilder
Microsoft.Identity.Client.Broker.BrokerExtension.WithBroker(Microsoft.Identity.Client.PublicClientApplicationBuilder, Microsoft.Identity.Client.BrokerOptions)'.
At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.7.2\netFramework\ExchangeOnlineManagement.psm1:754 char:21
+                     throw $_.Exception.InnerException;
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], MissingMethodException
    + FullyQualifiedErrorId : Method not found: 'Microsoft.Identity.Client.PublicClientApplicationBuilder Microsoft.Identity.Client.Broker.BrokerExtension.WithBroker(Microsoft.Identity.
   Client.PublicClientApplicationBuilder, Microsoft.Identity.Client.BrokerOptions)'.

Environment Information + PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.22000.3260
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22000.3260
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

nick-waterhouse avatar May 15 '25 21:05 nick-waterhouse

Any update with this issue?

Aussupport avatar May 29 '25 04:05 Aussupport

Further bump to this one. The error message I get this month looks as follows:

Method not found: 'Microsoft.Identity.Client.PublicClientApplicationBuilder
Microsoft.Identity.Client.Broker.BrokerExtension.WithBroker(Microsoft.Identity.Client.PublicClientApplicationBuilder,
Microsoft.Identity.Client.BrokerOptions)'.
At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.8.0\netFramework\ExchangeOnlineManagement.psm1:754
char:21
+                     throw $_.Exception.InnerException;
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], MissingMethodException
    + FullyQualifiedErrorId : Method not found: 'Microsoft.Identity.Client.PublicClientApplicationBuilder Microsoft.Identity
   .Client.Broker.BrokerExtension.WithBroker(Microsoft.Identity.Client.PublicClientApplicationBuilder, Microsoft.Identity.C
  lient.BrokerOptions)'.

nick-waterhouse avatar Jun 18 '25 20:06 nick-waterhouse

Same problem, following

jamaisx avatar Jul 04 '25 13:07 jamaisx

Same issue, also following.

Error occurs with ExchangeOnlineManagement version 3.7.2 as well as with the current version 3.8.0. Doesn't occur with version 3.6.0.

Connecting to {ExchangeOnline}...❌
Partial Export file was saved at: C:\Users\MyUserName\AppData\Local\Temp\758eb05d-2089-43bd-95f0-6622f127c643.partial.ps1
Methode nicht gefunden: "Microsoft.Identity.Client.PublicClientApplicationBuilder
Microsoft.Identity.Client.Broker.BrokerExtension.WithBroker(Microsoft.Identity.Client.PublicClientApplicationBuilder, Microsoft.Identity.Client.BrokerOptions)".
In C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.7.2\netFramework\ExchangeOnlineManagement.psm1:754 Zeichen:21
+                     throw $_.Exception.InnerException;
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], MissingMethodException
    + FullyQualifiedErrorId : Methode nicht gefunden: "Microsoft.Identity.Client.PublicClientApplicationBuilder Microsoft.Identity.Client.Broker.BrokerExtension.WithBroker(Microsoft.Ident  
   ity.Client.PublicClientApplicationBuilder, Microsoft.Identity.Client.BrokerOptions)".

This is my DSC command:

$Credential = Get-Credential
$Components = @("EXOAcceptedDomain", "EXOActiveSyncDeviceAccessRule", "EXOAddressBookPolicy", "EXOAddressList", "EXOAntiPhishPolicy", "EXOAntiPhishRule", "EXOApplicationAccessPolicy", "EXOAtpPolicyForO365", "EXOAuthenticationPolicy", "EXOAuthenticationPolicyAssignment", "EXOAvailabilityAddressSpace", "EXOAvailabilityConfig", "EXOCalendarProcessing", "EXOCASMailboxPlan", "EXOCASMailboxSettings", "EXOClientAccessRule", "EXODataClassification", "EXODataEncryptionPolicy", "EXODistributionGroup", "EXODkimSigningConfig", "EXOEmailAddressPolicy", "EXOGlobalAddressList", "EXOGroupSettings", "EXOHostedConnectionFilterPolicy", "EXOHostedContentFilterPolicy", "EXOHostedContentFilterRule", "EXOHostedOutboundSpamFilterPolicy", "EXOHostedOutboundSpamFilterRule", "EXOInboundConnector", "EXOIntraOrganizationConnector", "EXOIRMConfiguration", "EXOJournalRule", "EXOMailboxAutoReplyConfiguration", "EXOMailboxCalendarFolder", "EXOMailboxPermission", "EXOMailboxPlan", "EXOMailContact", "EXOMailTips", "EXOMalwareFilterPolicy", "EXOMalwareFilterRule", "EXOManagementRoleAssignment", "EXOManagementRoleEntry", "EXOMessageClassification", "EXOMobileDeviceMailboxPolicy", "EXOOfflineAddressBook", "EXOOMEConfiguration", "EXOOnPremisesOrganization", "EXOOrganizationConfig", "EXOOrganizationRelationship", "EXOOutboundConnector", "EXOOwaMailboxPolicy", "EXOPartnerApplication", "EXOPerimeterConfiguration", "EXOPlace", "EXOPolicyTipConfig", "EXOQuarantinePolicy", "EXORecipientPermission", "EXORemoteDomain", "EXOReportSubmissionPolicy", "EXOReportSubmissionRule", "EXOResourceConfiguration", "EXORoleAssignmentPolicy", "EXORoleGroup", "EXOSafeAttachmentPolicy", "EXOSafeAttachmentRule", "EXOSafeLinksPolicy", "EXOSafeLinksRule", "EXOSharedMailbox", "EXOSharingPolicy", "EXOTransportConfig", "EXOTransportRule")

Export-M365DSCConfiguration -Credential $Credential -Path $OutputFolder -FileName $FileName -Components $Components

My PowerShell version:

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.26100.4652
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.4652
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Update: My DSC version: 1.25.723.1

Update: This (https://github.com/microsoftgraph/msgraph-sdk-powershell/discussions/3254#discussioncomment-13328568) seems to help, but the root cause still persists with the ExchangeOnlineManagement module after version 3.7.0

theonlychrisk avatar Jul 23 '25 15:07 theonlychrisk

Also mentioned in https://github.com/microsoft/Microsoft365DSC/issues/6139 and https://github.com/microsoft/Microsoft365DSC/issues/6168

theonlychrisk avatar Jul 25 '25 07:07 theonlychrisk

Are you using other modules on the same machine or a plain installation of M365DSC and its dependencies? If yes, what happens if you uninstall all modules and start from scratch?

FabienTschanz avatar Jul 25 '25 14:07 FabienTschanz

Are you using other modules on the same machine or a plain installation of M365DSC and its dependencies? If yes, what happens if you uninstall all modules and start from scratch?

Hi Fabien,

thanks for the reply.

I've been able to reproduced the error at:

  1. A plain installation of M365 DSC and its dependencies inside a VM with a fresh Windows 11 24H2 installation.
  2. My original system, also with a plain installation of M365 DSC and its dependencies after removing all modules beforehand.

Error message

Connecting to {ExchangeOnline}...❌
Partial Export file was saved at: C:\Users\LAB\AppData\Local\Temp\647a61a3-0e52-4aaf-9e3f-e238b58c5910.partial.ps1
Methode nicht gefunden: "Microsoft.Identity.Client.PublicClientApplicationBuilder 
Microsoft.Identity.Client.Broker.BrokerExtension.WithBroker(Microsoft.Identity.Client.PublicClientApplicationBuilder, Microsoft.Identity.Client.BrokerOptions)".
In C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.8.0\netFramework\ExchangeOnlineManagement.psm1:754 Zeichen:21
+                     throw $_.Exception.InnerException;
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], MissingMethodException
    + FullyQualifiedErrorId : Methode nicht gefunden: "Microsoft.Identity.Client.PublicClientApplicationBuilder Microsoft.Identity.Client.Broker.BrokerExtension.WithBroker(Microsoft.Identity.  
   Client.PublicClientApplicationBuilder, Microsoft.Identity.Client.BrokerOptions)".

PS version

PS C:\Users\LAB> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.26100.4652
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.4652
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

M365DSC version

PS C:\Users\LAB> Get-Module Microsoft365DSC -ListAvailable | select ModuleBase, Version

ModuleBase                                                            Version   
----------                                                            -------
C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.25.723.2 1.25.723.2

theonlychrisk avatar Jul 29 '25 13:07 theonlychrisk

@theonlychrisk Can you quickly share the entire command you're executing and which workloads you want to export (except EXO)? Something fancy, does it work if you shuffle the order of the workloads so that ExchangeOnline is at the beginning of them? What happens if you export only ExchangeOnline and nothing other?

I believe this could be an assembly conflict if multiple versions of a specific .dll are loaded. A thing we already reported multiple times to the authors of the modules - But they won't listen sadly.

Edit: Nvm, I saw the command in a comment a bit earlier. Overlooked it. But can you still try with another workload first, e.g. AAD?

Edit 2: Now I get the error as well. Very surprised about that, I've been running Exchange exports almost daily over the last weeks... Will check it out!

FabienTschanz avatar Jul 29 '25 21:07 FabienTschanz

Okay so with the latest prerelease version of ExchangeOnlineManagement v3.9.0-Preview1 it works without any issues. The problem is with the Microsoft.Identity.Client component used by the module to authenticate. It seems like a method of a class wasn't properly functioning or missing in the specific version 4.66.1.0 (v3.9.0-Preview1 uses 4.68.0). This means that we have to wait for the next stable release of the module to incorporate it into M365DSC.

If you use PowerShell 7, it will work without issues. Also, from what I just tested, Certificate with Thumbprint also works (in PS5.1)

FabienTschanz avatar Jul 29 '25 21:07 FabienTschanz

@FabienTschanz

That's correct, the error occurs if another workload (e.g. AAD) is processed before EXO, which leads to the described issue with Microsoft.Identity.Client.

For now, I'll split my scripts that contain mixed workloads into dedicated scripts which only handle a single workload type. This works fine for me until the new EXO v3.9.0 is released.

Thanks for your help with this!

theonlychrisk avatar Aug 01 '25 15:08 theonlychrisk

You‘re welcome. I‘ll keep you posted and update the issue accordingly as soon as we have news on the matter.

FabienTschanz avatar Aug 01 '25 19:08 FabienTschanz

Just adding an update: it appears v3.9.0 of EXO module is no longer in preview if that was a blocker @FabienTschanz

bitdeft avatar Aug 26 '25 23:08 bitdeft

@bitdeft PR is open, waiting for approval to merge.

FabienTschanz avatar Aug 27 '25 15:08 FabienTschanz