Hello, @Gurudas,
Welcome to the Microsoft Q&A platform!
Based on your description, I understand that you want to get validation and explanation of the PowerShell command “ Test-OAuthConnectivity -UserPrincipalName ‘john.dave@contoso.com’”.
According to the official documentation, the “Test-OAuthConnectivity” command is used to verify that OAuth authentication is working properly between Exchange and the partner application.
As for the second half of “-UserPrincipalName ‘john.dave@contoso.com’, this specifies the user principal name (UPN) of the user account for which the OAuth connection is to be tested. The UPN is usually the user's email address. To summarize, this command runs a test to check if OAuth authentication works for the user john.dave@contoso.com.
However, I noticed that there is no “UserPrincipalName” parameter in the official documentation, so this may not be a generic parameter, and its usage may depend on a particular version or environment. As an alternative, I used the following command to test the OAuth connectivity from the specified mailbox to the specified EWS endpoint and got the result.
Test-OAuthConnectivity -Service <ServiceName> -TargetUri <TargetUri> -Mailbox <Mailbox> -Verbose
For information about the parameter sets in the Syntax section, see the screenshot below. If you want to get more details about the parameters and scenarios used by the “Test-OAuthConnectivity” command, please click on Test-OAuthConnectivity (ExchangePowerShell) | Microsoft Learn for reference.
Finally, due to the limitations of my test environment, the commands I tested differ somewhat from the ones you provided. If you are primarily concerned with the connectivity of a particular user, the second command is more convenient (if this parameter is available in your environment). If you need to test the connectivity of a service in detail, especially an EWS service, then the first command is more suitable. You can make your own choice according to your environment and needs.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Thank you for your support and understanding.
Best Wishes,
Alex Zhang