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

Getting the following error when using the Export-CrmSolution commandlet #498

Closed AshawDyn closed 2 years ago

AshawDyn commented 2 years ago

VERBOSE: Using the supplied single filter of uniquename 'like' DynamicsAssign Get-CrmRecordsByFetch : System.Management.Automation.RuntimeException: Crm Service not initialized

AshawDyn commented 2 years ago

I'm using a clientid and secret with the Connect-CrmOnline to get the -conn parameter

AshawDyn commented 2 years ago

I assume I need to use the Get-Crmconnection, but I don't see how to use it with a clientid and secret

AshawDyn commented 2 years ago

Fixed it myself.

My Get-CRMCOnnection was wrong.

I changed it to: Get-CrmConnection -ConnectionString "AuthType=ClientSecret;Url=$DynamicsURL;ClientId=$DAppId;Secret=$Secret"

Then it started working

seanmcne commented 2 years ago

Thanks for the update @AshawDyn!

In most cases, I suggest going with Connect-CrmOnline in lieu of Get-CrmConnection directly. Get-CrmConnection is fine, but the format can be a real struggle at times and connect-CrmOnline effectively takes a slightly more standardized approach at building the connection string for the top scenarios including clientSecret and other methods. If I'm being honest, I've used the module with Connect-CrmOnline with -verbose to build connection strings for other apps :)