Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

Export fails due to MSCloudLoginAssistant variable complain

Open 1Dimitri opened this issue 6 months ago • 3 comments

Description of the issue

Update from 1.26.520.1 to 1.26.527.1 on the same machine

Trying to export various workloads fails. Narrowing down to export of one single resource gives me a empty variable with underlying MSCloudLoginAssistant parameters

I'm using the CertificateThumbprint, ApplicationID, TenantID tuple,

Did something change?

Microsoft 365 DSC Version

1.26.527.1

Which workloads are affected

Azure Active Directory (Entra ID)

The DSC configuration

N/A

Verbose logs showing the problem

Export-M365DSCConfiguration -Path . -Components @('AADConditionalAccessPolicy') @creds_M365DSC
Exporting Microsoft 365 configuration for Components: AADConditionalAccessPolicy

Authentication methods specified:
- Service Principal with Certificate Thumbprint

Starting export in sequential mode...
Connect-MgGraph : ClientCertificateCredential authentication failed: Keyset does not exist
At C:\Program Files\WindowsPowerShell\Modules\MSCloudLoginAssistant\1.1.66\Workloads\MicrosoftGraph.ps1:96
char:25
+ ...             Connect-MgGraph -ClientId $Script:MSCloudLoginConnectionP ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-MgGraph], AuthenticationFailedException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph

Error Log created at {file://D:/Users/Dimitri/AppData/Local/Temp/2/11528-M365DSC-ErrorLog.log}
[1/1] Extracting [AADConditionalAccessPolicy] using {CertificateThumbprint}...❌
    An error occurred while exporting resource {AADConditionalAccessPolicy}: Authentication needed. Please call Connect-MgGraph.
⌛ Export took {1 seconds} for {0 instances}
Successful exports: {0}
Failed exports: {1}
❌ Export completed with errors.

Environment Information + PowerShell Version


1Dimitri avatar Jun 01 '26 10:06 1Dimitri

We didn‘t change anything in our logic for certificate authentication. Keyset does not exist is something I haven‘t seen before and I don‘t think it‘s related to M365DSC. Can you check with suggestions from this link?

https://forums.powershell.org/t/connect-mggraph-keyset-does-not-exist-error-when-trying-to-authenticate-with-certificate/24052/3

FabienTschanz avatar Jun 01 '26 12:06 FabienTschanz

Okay this one is on me :| Since the introduction of the DLL, I have a script to kill powershell sessions since otherwise the uninstallation of an older version during upgrading doesn't work. Under a mix of PWSH / Powershell running processes, one of the session is not relaunched as administrator, thus no access to the certificate's private key, thus the error message.

1Dimitri avatar Jun 02 '26 06:06 1Dimitri

Got it, thank you.

FabienTschanz avatar Jun 02 '26 06:06 FabienTschanz