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

    SILVER CONTRIBUTOR
    Posted 17 days ago
    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:
    3.3.0.862
    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
    Winton
    ------------------------------
    Conference-CRMUG_200x200


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

    SILVER CONTRIBUTOR
    Posted 16 days ago

    Pete,

    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.
    https://github.com/seanmcne/Microsoft.Xrm.Data.PowerShell

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

    Wayne.



    ------------------------------
    Wayne Wittman
    CRM Administrator
    MiTek Industries Inc.
    Clifton NJ
    ------------------------------

    Conference-CRMUG_200x200


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