Running Exchange PowerShell cmdlets using OAuth2 acces token to authenticate RRS feed

  • Question

  • Hello,

    I want to run Exchange PowerShell cmdlets from C#, and doing so, I am calling New-PsSession.

    In my case, I am trying to use an access token to authenticate (I have an Exchange Online app that uses a certificate for authentication) because I don't want to get prompted for credentials. I saw several posts about doing so, but I could not get it to work.

    What I've tried: Create PSCredentials with the token new PSCredentials("",token) 

    but ran into 2 problems:

    1. I cannot use the syntax found in the article and create the PSCredentials with password only, because it throws an error that the username cannot be empty.

    2. If I try to use a real username, but pass token as password, I get 403 unauthorized.

    Is there a way to do this?

    Friday, July 12, 2019 11:21 AM

All replies