Hey everyone, I have a new exciting project to share with the community. Kenichiro and I recently released a scripted PowerShell module (PSM1) called Microsoft.Xrm.Data.Poweshell. This PowerShell module enables admins to query and manipulate Dynamics CRM Data. It supports On-Prem and Online and primarily targets releases CRM 2013 and greater, however I have been able to connect to CRM 2011 for basic operations.
So, what can you do with this PowerShell module?
- Query, Create, Update, and Delete CRM records
- Execute workflows, change business units, assign/remove roles
- Review plugin traces (in CRM version 7.1+ and higher) and Mailbox Trace data
- Review customization solution import results (including the result XML)
- Import, export, and publish customizations
- much more!
You can download the module by following the link, but I’ve also included installation instructions at the bottom of the post: Xrm.Data.Poweshell: PowerShell for Dynamics CRM Organization Data or you can use the short URL of: https://aka.ms/CRMPowerShell
Reason #1: customers, our customers have been asking for this and Ken and I wanted to make management and querying CRM data easier and accessible to everyone. While the XrmTooling Powershell snapin provides a connection and proxy back to CRM, the proxy is a bit difficult to work with and admins usually just want to get work done. To enable this, Ken and I targeted the most common operations admins and developers would want based on feedback we’ve heard in the field with customers. Additionally, we’ve packaged the tooling DLL with our module meaning you don’t have to register the snapin to connect to CRM when using this module.
Also, with CRM onprem and online, admins need a standardized way to query data and configure their instances of CRM (no matter where they’re hosted). This module will allow you to import it and get right to work, query data, query metadata, get entity attributes, verify record data that isn’t easily viewable in CRM and more. We did our best to follow the common patterns for naming like: ‘get-crmRecords’, ‘connect-CrmOnlineDiscovery’.
Who should use this?
The target audience for the module is for IT Admins, CRM Admins, and developers – it’s very helpful to verify attribute metadata, get record counts, look at entity metadata, etc. The module provides basic and common functions to allow easy downloading and usage of the module. We also released several samples to illustrate common uses.
- We’re looking at listing this in a repository like Chocolatey (https://chocolatey.org/) so you can install it via OneGet – this is a work in progress and something we haven’t attempted yet – if you have any tips please share!
- I hope to try and get a screencast recorded showing some simple uses of the module to help with getting started quickly
- We will keep adding more functions to the module, at the same time we’ll add more sample scripts so that you can simply modify them and and use them immediately. Any feedback is welcome, so please post Questions in the Q&A section here: https://gallery.technet.microsoft.com/scriptcenter/PowerShell-functions-for-16c5be31/view/Discussions#content
- AzureAutomation – currently it appears XrmTooling has some dependencies that we believe are not compatible with Azure Automation (at least not without some tweaking). Ken and I looking into this, we’ll do what we can to make the current version work or try and get something out to work in Azure Automation if at all possible.
We look forward to your feedback and as always, thanks for reading!
PowerShell Module Installation Instructions:
1. You can download the module here installation instructions are below: Microsoft.Xrm.Data.Poweshell: PowerShell for Dynamics CRM Organization Data
2. Download the zip file and save it to disk
3. Right-click the Zip file and press properties
4. On the properties page: Check "Unblock" checkbox and click "OK", or simply click "Unblock" the button could look differently depending on the OS.
5. Extract the zip file and copy "Microsoft.Xrm.Data.PowerShell" folder to one of the following folders:
The image below shows this module copied to User Profile. If you want all users to have the module accessible on the computer, copy them to System Wide PowerShell module folder instead. If you do not have the folder, you can manually create them.
6. The module is not signed and you may need to change Execution Policy to load the module. You can do so by executing following command (Please refer to Set-ExecutionPolicy for more information).
Set-ExecutionPolicy –ExecutionPolicy RemoteSigned –Scope CurrentUser
7. Open PowerShell and run following command to load the module.
8. Here is a sample on how to query all accounts from a CRM Online org called “Contoso”
Import-Module Microsoft.Xrm.Data.Powershell -verbose –force
$me = Get-Credential
$myOrg = Get-CrmConnection -Credential $me -DeploymentRegion NorthAmerica –OnlineType Office365 –OrganizationName CONTOSO -verbose
Get-CrmRecords -conn $myOrg -EntityLogicalName systemuser -Fields *
#now retrieve all users who have a fullname like ‘Sean%’
Get-CrmRecords -conn $myOrg -EntityLogicalName systemuser -Fields * -FieldName fullname -FilterOperator like -FilterValue ‘Adventure%’