Manage Dynamics CRM data and settings with PowerShell!

More information on our team
Podcasts
YouTube Channel
More info on the PFE Dynamics CRM Services
Dynamics CRM 2011, 2013 and 2015 useful Tools and Features
Release Dates, Build Numbers, and Collateral
Most popular posts on the CRM in the FIeld blog

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: http://aka.ms/CRMPowerShell

Why?

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.

What’s next?

  • 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! 5545.wlEmoticon 2D00 smile 5F00 3F9A974E Manage Dynamics CRM data and settings with PowerShell! 
  • 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! 

Sean McNellis & Kenichiro Nakamura

3806.103013 5F00 0027 5F00 CRM2011andA1 Manage Dynamics CRM data and settings with PowerShell!
@seanmcne
@pfedynamics | http://www.pfedynamics.com

8270.103013 5F00 0027 5F00 CRM2011andA2 Manage Dynamics CRM data and settings with PowerShell! 7607.103013 5F00 0027 5F00 CRM2011andA3 Manage Dynamics CRM data and settings with PowerShell! 6457.103013 5F00 0027 5F00 CRM2011andA4 Manage Dynamics CRM data and settings with PowerShell! 7041.103013 5F00 0027 5F00 CRM2011andA5 Manage Dynamics CRM data and settings with PowerShell!

——————————————————————————————–

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.

unblock Manage Dynamics CRM data and settings with PowerShell!

5. Extract the zip file and copy “Microsoft.Xrm.Data.PowerShell” folder to one of the following folders:
   • %USERPROFILE%\Documents\WindowsPowerShell\Modules
   • %WINDIR%\System32\WindowsPowerShell\v1.0\Modules 

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.

individual Manage Dynamics CRM data and settings with PowerShell!

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.

Import-Module Microsoft.Xrm.Data.Powershell

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%’

Any plans for Orion Sp1 +

It supports the versions listed above (2013 and higher), Orion is 6.0 (aka CRM 2013) and Leo is 6.1 (2013 SP1), Vega is 7.0 (2015) and Carina is 7.1 (online only).  

This entry passed through the Full-Text RSS service – if this is your content and you’re reading it on someone else’s site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.

Dynamics CRM in the Field