Hello @Ken Nye
The error usually occurs if the certificate added in Azure AD app registration is deleted in local certification store.
I have one app registration with certificate named graphcert07
added in it:
Now, I ran certmgr.msc in Windows Run to open Certificate Manager and deleted graphcert07
certificate as below:
When I tried to connect Microsoft Graph PowerShell using that certificate, I too got same error like this:
$tenantId = "tenantId"
$clientId = "appId"
$thumbprint = "65876F7BB07B2Cxxxxxxxxxxxx"
Connect-MgGraph -ClientId $clientId -TenantId $tenantId -CertificateThumbprint $thumbprint
Even if the certificate is present in Azure AD app registration, it should also present in local certification store.
In your case, open Certificate Manager and check whether certificate named Azure_cert
thumbprint is present in it or not.
If it’s not present, delete the existing certificate in Azure AD app registration and upload new certificate to it.
I created one new certificate by running below PowerShell commands:
$certname = "mygraphcert"
$cert = New-SelfSignedCertificate -Subject "CN=$certname" -CertStoreLocation "Cert:\CurrentUser\My" -KeyExportPolicy Exportable -KeySpec Signature -KeyLength 2048 -KeyAlgorithm RSA -HashAlgorithm SHA256
Export-Certificate -Cert $cert -FilePath "C:/mycerts/$certname.cer" ## Specify your preferred location
Now, I uploaded this new certificate to Azure AD app registration by deleting the old one:
When I tried to connect Microsoft Graph PowerShell using new certificate, I got the response successfully as below:
$tenantId = "tenantId"
$clientId = "appId"
$thumbprint = "91792D97E4xxxxxxxxxxxxxxx"
Connect-MgGraph -ClientId $clientId -TenantId $tenantId -CertificateThumbprint $thumbprint
Get-MgUserDefaultCalendar -UserId "userobjectId"
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.
If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.