question

StephanG avatar image
0 Votes"
StephanG asked SharonZhao-MSFT commented

Service principal for Automated Powershell - Access is denied although Directory Roles are assigned

Hi everyone,

I am having a problem to enroll automated Powershells with service principals.
I am trying to connect to Exchange Online & Teams Online by using this doc
https://docs.microsoft.com/en-us/powershell/azure/active-directory/signing-in-service-principal?view=azureadps-2.0

I created the App - i assigned it the right directory roles.
But neither Exchange nor Teams is working - i am getting:
get-team : Forbidden in /v1.0/teams/ endpoint
or
New-ExoPSSession : Connecting to remote server outlook.office365.com failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\2.0.5\netFramework\ExchangeOnlineManagement.psm1:475 char:30

The signin says "Success" in the logs.

any directions where i should go next?

BR
Stephan

office-teams-windows-itprowindows-server-powershelloffice-exchange-online-itpro
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@StephanG,
You could refer to this article to use App-only authentication for unattended scripts in the EXO V2 module.


0 Votes 0 ·

1 Answer

StephanG avatar image
0 Votes"
StephanG answered SharonZhao-MSFT commented

Now i created a new enterprise app for Exchange
Followed everything - and now i am stopped at this :)

I imported the certificate to the "CurrentUser" My store - it is working for the Teams Powershell like this
101017-image.png


Server (W2K12R2) was restarted

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Ok - can connect now - i copied my command to another window - and there was a hidden sign before the thumbprint.
Removed it - is working now :)

0 Votes 0 ·

@StephanG,
Thanks for your sharing. I'm glad that your problem is resolved.
I converted your comments as answer. You could accept it as answer to help more people with the same problem. Thanks for your understanding.

0 Votes 0 ·