Microsoft.Xrm.Data.Powershell: PowerShell for Dynamics CRM Organization Data

These PowerShell functions are for Dynamics CRM data operations such as CRUD and manipulating User and System Settings. This module depends on XrmTooling version or higher but functions on Dynamics CRM Online and 2013, 2015 versions.

4.8 Star
4,563 times
Add to favorites
E-mail Twitter Digg Facebook
  • Get-CrmPackages Error
    1 Posts | Last post January 26, 2016
    • When I'm executing Get-CrmPackages powershell command,I'm getting the following error:
      Get-CrmPackages : Could not load file or assembly 'Microsoft.Xrm.Tooling.PackageDeployment.CrmPackageCore, Version=, Culture=neutral,
      PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
      At line:1 char:1
      + Get-CrmPackages
      + ~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Get-CrmPackages], FileNotFoundException
          + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.Xrm.Tooling.PackageDeployment.Powershell.Cmdlets.GetCrmPackageCommand
      Not only this but executing any command from Microsoft.Xrm.Tooling.PackageDeployment gives me error
      Get-Command -PSSnapin Microsoft.Xrm.Tooling.PackageDeployment
      Get-CrmPackages                                    Microsoft.Xrm.Tooling.PackageDeployment
      Import-CrmPackage                                  Microsoft.Xrm.Tooling.PackageDeployment
      Anybody knows what I'm missing?
  • New-CrmMoney only takes Integer value?
    3 Posts | Last post November 09, 2015
    • Hi Ken, 
      Should New-CrmMoney take decimal value? Currently it only takes integer value. 
    • Hi Kevin,
      You are absolutely right. I will change it to double in v1.7, which will be released in a week as we also put more validations for Import-CrmSolutions, too.
    • I fixed it at v1.7. Please download the latest release from GitHub which you can find in Description
  • Two scripting bugs
    6 Posts | Last post November 05, 2015
    • Hi Ken,
      Thank you and Sean for this great Powershell module.
      Just noticed two bugs:
      First, in the last cmd: Test-XrmTimerStop, it trys to get the timer from Global scope, in fact, it's created in Script scope.
      Second, in Line 587, $Id = $originalRecord[$EntityLogicalName + "id"], this code won't work for SystemForm (like dashboard, main form, etc), because the PrimaryID attribute is "formid" not "systemformid".
    • Kevin,
      Thanks for your great feedback. I will fix it in v1.6 for both issues and will release early nest week!
      If you notice anything else or feature request, please feel free to add more comments.
    • Hi Ken, 
      Thanks for getting back so quickly. I did run the following command:
      Get-CrmEntityAllMetadata -OnlyPublished $True | select LogicalName, PrimaryIdAttribute | where { $_.LogicalName + "id" -ne $_.PrimaryIdAttribute}
      It returns 57 records whose PrimaryIdAttribute is not "LogicalName" + "Id". 
      Maybe we should get/cache the metadata first before mapping out PrimaryIdAttribute from LogicalName?
      Just for your thoughts and look forward to the changes soon. 
    • Hi Kevin,
      Thanks for your feedback, I also check it by directly querying the database and found entities with different naming for id. However I did handle UserSetting,SystemForm and Activity Entities this time as others are more internal entities.
      Doing Metadata check is something I also consider but when we think about performance, I thought we should avoid it. So I didn't put metadata check this time. I just released v1.6, so please test when you have time! Ken
    • Hi Ken, 
      Thank you for the quick updates. It's working great. 
      Yes, we should not concern too much about internal entities. If we query metadata per function call, the performance will have a hit. If we query metadata and cache it when connecting to CRM organization, this shall be solving the issue. This will be working for custom Activity entity as well, whose primary field is "activityid". 
      Will leave this to your expert hands for possible future enhancements. 
      Thanks again, 
    • Hi Kevin, 
      This is great feedback. Yes I should have known you may have custom activities which end up having same issue. Getting all metadata is a bit heavy work for both calling and caching and so far Activity is the concern. But if we can download minimum amount of metadata when initiating the connection, or provide -IsActivity parameter, would be solve the issue. Let me think about this. 
      Download metadata will solve the issue forever though..
  • Import-CrmSolution says it is completed, but behaves like a no-op
    4 Posts | Last post November 02, 2015
    • Hi,
      I'm using Import-CrmSolution on CRM Online to import multiple managed solutions.
      If I import 2 or more managed solutions one after the other, they seem to succeed from a PowerShell perspective, but actually only the first one has succeeded. This is because the PowerShell cmdlet returns, but apparently CRM Online is busy working on the 1st solution and the other calls to Import-CrmSolution happily succeed, but nothing happens - i.e. the 2nd and 3rd solutions are never deployed.
      Instead, after the 1st solution is imported, I have to wait a bit, then attempt to make a new connection to CRM via Get-CrmConnection; and if CRM is busy processing the 1st solution, then this command keeps failing. And finally when I do get a connection to CRM, then I can import the 2nd solution. Same exercise in waiting, reconnecting, and then the 3rd solution and so on.
      It would be ideal if the Import-CrmSolution cmdlet returned a job - which indicates when CRM Online is ready to accept subsequent requests.
    • Thanks for your feedback.
      We just released v1.5 and I tried to repro the issue but I couldn't. So it may be fixed already. If it didn't please let me have sample repro script. I am simply testing this.
      Import-CrmSolution -SolutionFilePath "C:\Users\crmadmin\Downloads\"
      Import-CrmSolution -SolutionFilePath "C:\Users\crmadmin\Downloads\"
    • Hi Ken,
      I'll try the new 1.5 version out on Monday and let you know. Thanks for the super quick response!
    • Hey Krish -
      I can confirm the behavior you're seeing, it's somewhat of an async event/operation (even though it's mostly sync).  TO combat that the cmdlet now will poll for a 'true' completion before proceeding - I have not been able to repro since.  If you want to see how it's working while importing make sure to include a -verbose flag on the import-CrmSolution call.  Let me know how it's working for you as well! 
  • Specified cast is not valid when updating crm system settings
    2 Posts | Last post October 24, 2015
    • I'm getting a "Specified cast is not valid" when trying to update a system setting (DisplayNavigationTour)
      The command that i'm using is:
      Set-CrmSystemSettings -conn $conn -DisplayNavigationTour $true
      Any help?
    • Thanks for the feedback. It's actually a bug and we fixed it today as v1.5.
      Please download the module again to test it.
  • Get-CRMConnection without -Credential
    2 Posts | Last post September 30, 2015
    • I was trying to see if it was possible to run Get-CRMConnection without using the -Credential flag so it would use the current user's credentials. I get the following error when I try this though:
      Get-CrmConnection : Object reference not set to an instance of an object.
      Is this possible?
    • Hi Mitt, Great question.
      Unfortunately, I do not have solution for that as underline xrm tooling does not accept current user credential, but need to explicitly pass PSCredentail, I believe.
  • Creating Users
    3 Posts | Last post September 29, 2015
    • I'm trying to create a new user, but the user never get's created and I get a returned GUID of 00000000-0000-0000-0000-000000000000 from the command. Is creating users supported? If so, are there certain fields that are required? Here is something similar to what I tried: 
      New-CrmRecord -conn $conn -EntityLogicalName systemuser -Fields @{"domainname"="domain\user";"firstname"="John";"lastname"="Doe";"incomingemaildeliverymethod"="0";"outgoingemaildeliverymethod"="0";"businessunitid"="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}
    • Thanks for your comment. Please download sample scripts which you can find in Description section. Some samples explain how to add CRM users Online and On-Prem.
    • Found the link. Thanks.
11 - 17 of 17 Items