seanmcne / Microsoft.Xrm.Data.PowerShell

This module uses the CRM connection from Microsoft.Xrm.Tooling.CrmConnector.Powershell and provides common functions to create, delete, query, and update data as well as functions for common tasks such as publishing, and manipulating System & CRM User Settings, etc. The module should function for both Dynamics CRM Online and On-Premise environment.
201 stars 64 forks source link

[FR] Connect-CrmOnline with Certificate #503

Closed Henry-Sir closed 1 year ago

Henry-Sir commented 2 years ago

Could you implement in the "Connect-CrmOnline" Cmdlet the possibility to connect to CRM via ClientId and certificate?

seanmcne commented 2 years ago

Yes, this has been on my list to try out for a while but I haven't had the chance to - as a test I think you could try the code below. My understanding is the connection code would open the store name and look specifically for the certificate with the given thumbprint. If you give it a try please let me know if it works as-is or if it takes some additional work.

$clientid = "ClientId"
$AppCertThumprint = "Thumbprint"
$CertStoreName = "Certificate store name"

$ConnectionString="ServiceUri=https://someenvironment.crm.dynamics.com/XRMservices/2011/Organization.svc;AuthType=Certificate;SkipDiscovery=true;ClientId=$clientId;thumbprint=$AppCertThumbprint;CertificateStoreName=$CertStoreName"

Connect-CrmOnline -ConnectionString $ConnectionString -Verbose
seanmcne commented 1 year ago

@Henry-Sir
If you have a moment, please let me know if that worked - thanks!