Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Connect to CRM online from Powershell using OAuth

  • 1.  Connect to CRM online from Powershell using OAuth

    Posted Oct 02, 2019 08:27 AM
    Using Microsoft.Xrm.Tooling.CrmConnector.Powershell, I can use Get-CrmConnection to connect to an online instance with a username and password. I want to connect as an application user using OAuth. I have registered the application in Azure, however there doesn't appear to be a way using Get-CrmConnection to specify the client secret, only the client id.

    The latest version states:
    ADAL 3.19+ is now required for this library.  ADAL 2.x clients will need to be updated to use ADAL 3.x+
    Added Support for Current User ID login when using Online flows with oAuth (Login control/connection string support )
    Added Support for ClientID Secret Auth when using oAuth flows. (connection string support )

    however I cannot find any examples of how to do this.

    All responses I've had on other forums have been for C# code which I do not want.

    Pete Axtell
    Academy - Online Interactive Learning from Experts

  • 2.  RE: Connect to CRM online from Powershell using OAuth

    Posted Oct 03, 2019 06:37 AM


    From what I have been reading it is recommended to use the version 2.x version of Microsoft.IdentityModel.Clients.ActiveDirectory since it supports passing credentials and the 3.x version does not.

    You may want to consider using Microsoft.Xrm.Data.PowerShell module.  I started doing some testing with it and it looks pretty complete.

    If you don't want to use it the module is all script calling the SDK assemblies.


    Wayne Wittman
    CRM Administrator
    MiTek Industries Inc.
    Clifton NJ

    Academy - Online Interactive Learning from Experts

If you've found this thread useful, dive deeper into User Group community content by role