Unable to catch Exception thrown by Connect-ExchangeOnline commandlet
Error Acquiring Token:|
System.Exception: Case when Message contains:AADSTS70011 Invalid scope. The scope has to be of the form "https://resourceUrl/.default"Mitigation: change the scope to be as expectedA configuration issue is preventing authentication - check the error message from the server for details. You can modify the configuration in the application registration portal. See https://aka.ms/msal-net-invalid-client for details. Original exception: AADSTS700027: The certificate with identifier used to sign the client assertion is not registered on application. [Reason - The key was not found., Thumbprint of key used by client: 'xxxx', Please visit the Azure Portal, Graph Explorer or directly use MS Graph to see configured keys for app Id 'appId'. Review the documentation at https://docs.microsoft.com/en-us/graph/deployments to determine the corresponding service endpoint and https://docs.microsoft.com/en-us/graph/api/application-get?view=graph-rest-1.0&tabs=http to build a query request URL, such as 'https://graph.microsoft.com/beta/applications/appId'].
I'm facing this exception when I attempt to connect to exchange online using EXO-Power shell via certificate based authentication using azure app registration. The certificate I uploaded and the certificate I used doesn't match. I tried to handle the exception by using try catch but the exception isn't getting caught. But I'm able to get the error in my logs. How to catch the error . Thanks in advance.