Connect-MgGraph : ClientCertificateCredential authentication failed: The certificate certificate does not have a private key.

Bojan Zivkovic 606 Reputation points
2025-05-15T18:11:42.86+00:00

Hi, PS code connecting to MS Graph works fine (inside scheduled task) when run as user is domain admin account:

Connect-MgGraph -TenantId $TenantID -AppId $AppID -Certificate $Cert -NoWelcome

However, when scheduled task is running under gMSA having even full permissions on certificate private key, Connect-MgGraph line above always fails:

Connect-MgGraph : ClientCertificateCredential authentication failed: The certificate certificate does not have a private key.

We always prefer to use gMSAs for scheduled tasks so sorting this out would be great.

Microsoft Security | Microsoft Graph
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.