Hi @Arkhaam
As this is your first time I would suggest you to have a look at this and brush up the basics
https://learn.microsoft.com/en-us/graph/powershell/get-started
The remote server returned an error: (401) Unauthorized for this error and for this
Various exchange services can be tested with online test connectivity tool from Microsoft. You may test the EWS connectivity as follows and see it works. If not adjust the code or server settings.
- Open https://testconnectivity.microsoft.com.
- Select Exchange Server as per your setup.
- Select Service Account Access and perform Test. Use the same parameters you use in code
Hope this Answers all your queries , if not please do repost back .
If an Answer is helpful, please click "Accept Answer" and upvote it : )