Great Power Tools for CRM Administrator: Microsoft.Xrm.Data.PowerShell module – Part I


Want to change CRM settings for 3,000 users? Or get CRM organization data without having to call a programmer? With Microsoft.Xrm.Data.PowerShell CRM PowerShell module recently published on TechNet, a CRM administrator can become highly productive. This module allow you to perform CRUD operations with Dynamics CRM data and change user and system Settings for both Dynamics CRM Online and On-Premise environments. Here is the good news—these CRM operations are using PowerShell, a skillset you already have for other administrative tasks. 

The download package also comes with sample scripts to illustrate how to:

  • Operate against multiple CRM organizations
  • Update multiple CRM user settings
  • Provisioning Language Pack
  • Add Azure Active Directory users and CRM Online users from CSV file
  • Add Active Directory users and CRM On-Premise users from CSV file
  • Add CRM On-Premise users from users under specific Active Directory OU

This blog article will guide you through the process of how to download and start using the powerful CRM PowerShell module. Our colleagues, Sean McNellis and Kenichiro Nakamura, implemented this wonderful PowerShell module. Also, Sean published another blog article–Manage Dynamics CRM data and settings with PowerShell! 

So let’s get started.


Step 1. Download PowerShell Module

You can download CRM PowerShell module from Microsoft.Xrm.Data.Powershell: PowerShell for Dynamics CRM Organization Data. Also, you can find more useful information here. 


Step 2. Unblock

Once you have successfully downloaded the file, right click the downloaded zip file and click “Properties”. Check “Unblock” checkbox and click “OK”. Depending on your OS versions, you can simply click “Unblock” button.


Step 3. Extract PowerShell module to the appropriate folder

You can extract PowerShell module to either User Profile folder or System Wide PowerShell module folder. If you want anyone to use the module on the computer, copy them to System Wide PowerShell module folder. If you do not have the folder, you can manually create them.

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  

Following image shows this module copied to System Wide PowerShell module folder.

 

 
Step 4. Check PowerShell version

As of writing of this blog article, the Microsoft.Xrm.Data.Powershell module requires PowerShell v4.0, so you should perform a PowerShell version check in your environment. To check your PowerShell version, you can access the PSVersion property from PSVersionTable to determine what version of Windows PowerShell is installed on your computer: $PSVersionTable.PSVersion.

 

 

Step 5. Set Execution Policy

The Microsoft.Xrm.Data.Powershell module is not signed, so your next step is to change Execution Policy to load the module. You can do so by executing following command:

Set-ExecutionPolicy –ExecutionPolicy RemoteSigned –Scope CurrentUser

Please refer to Set-ExecutionPolicy for more information.

 

Step 6. Load PowerShell Module

At this point, you can load Microsoft.Xrm.Data.Powershell module. To load the PowerShell module, you can run the following command:

Import-Module Microsoft.Xrm.Data.Powershell

 

Step 7. Connect to CRM Orgnization

You are almost ready to unleash the power of this awesome module, the last step before you can use it is to create a connection to your CRM organization. You can run the following command to connect to Dynamics CRM Organization via the Xrm Tooling GUI:

Connect-CrmOnlineDiscovery –InteractiveMode

This will launch a PowerShell Interactive Login window. This windows gives you the option to connect to Dynamics CRM Online or On-Premise environment. Once you provide necessary information, you are connected to your CRM organization.

 

 

 

Next Steps

In Part II of this post, I’ll include additional samples to create a sample account, update the account, then remove the account. We are also going to look at how to make user setting changes via PowerShell.

 

Related References

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

Manage Dynamics CRM data and settings with PowerShell! 

Using Windows PowerShell 

 

Thanks,

Andy Zhang

Microsoft Premier Field Engineer

Comments (1)

  1. Rahul Gupta says:

    Great Post!!!

Skip to main content