Search code examples
powershelldynamics-crm

CRM 2015 Powershell Get-Organizations fails with Xrm Sdk not found


I'm following the steps enumerated in the Microsoft Technet library to connect to CRM using Powershell - https://technet.microsoft.com/en-us/library/dn689040(v=crm.7).

I was successful in completing "Register the cmdlets" section, but I could not complete #2 of "Use the cmdlet to retrieve organizations from CRM" section.

the error is:

    Get-CrmOrganizations : Could not load file or assembly 'Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
At line:1 char:12
+ $CRMOrgs = Get-CrmOrganizations –ServerUrl http://myserver:5555
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-CrmOrganizations], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.Xrm.Tooling.CrmConnector.Powershell.Commands.G
   etOrganizations

the computer I'm executing this on did not have anything else installed other than the database server itself (in other words executing this on the db server)

has anyone encountered this issue? if so, do you know how to resolve it?


Solution

  • I just checked that there is an error in the SDK bundle - for version 2015, the Microsoft.Xrm.Tooling.CrmConnector.Powershell.dll (version 1.0.0.0) is dependent upon SDK 2013 (version 6.0.0.0): sdk but Microsoft.Xrm.Tooling.Connector is dependent upon version 7.0.0.0, so version 2015: sdk2015 So this is clearily a bug in SDK. Simply download SDK 2013 and copy your Microsoft.Xrm.Sdk.dll into the bin folder (where your Microsoft.Xrm.Tooling.CrmConnector.Powershell.dll resides)

    You can also try downloading SDK for CRM 2016 - it usually is working correctly with older CRM versions, so powershell cmdlets should also be working fine with CRM 2015.