powershell_icon_thumb6_thumbWith the recent highly anticipated release of CRM 2011, you now have the ability to manage some parts of Dynamics CRM 2011 with PowerShell!  Ok not entirely, but it is a great start from Microsoft to providing the incredible flexibility of PowerShell to Dynamics CRM.  More specifically, you are able to script deployment management tasks only.  For the time being, you can only run PowerShell with CRM on-premise, NOT CRM Online.  Currently the functionality of PowerShell for CRM 2011 is limited, so this mostly would pertain to either to large organizations, or companies that do CRM hosting through SPLA agreements.  With these new PowerShell cmdlets, you are able to do things like:

  • Create/Remove Deployment Administrators
  • Create/Import CRM Organizations
  • Review and configure CRM Organization settings

A Side Note on PowerShell ISE

When working with PowerShell, I will always recommend using the PowerShell ISE application.  It's a feature included in PowerShell 2.0, which is in Windows Server 2008 R2 and Windows 7 (or if you download PowerShell 2.0).  It beats the regular PowerShell command window by a mile.  In Windows Server, go to Server Manager –> Features –> and check the box for Windows PowerShell Integrated Scripting Environment (ISE).

Installing PowerShell ISE

Once installed, it’s accessible under Start –> Accessories –> Windows PowerShell –> Windows PowerShell ISE.  There’s loads of good info already out there on PowerShell in general, so I won’t reiterate them here.  Now that we have that out of the way … on to CRM!

CRM 2011 and PowerShell – Better Together!

Now you’ve got your powerful ISE application open, let’s see what we can do.  As with SharePoint, you need to load the CRM PowerShell snapin dll file into the PowerShell console.  This snapin is what provides all of the cmdlets you will use in your commands and scripts.  Let’s load the snapin:

Add-PSSnapin Microsoft.Crm.PowerShell

Let’s see what commands we have.  The first command will return all cmdlets, and format it in a simple table view showing only the name.  If you want more detail, try the second command:

Get-Command -PSSnapin "Microsoft.Crm.PowerShell" | format-table name
Get-Command -PSSnapin "Microsoft.Crm.PowerShell" | select name, definition | format-list

It returns a simple list of all the cmdlets as below:


How many is that?  Count it!

(Get-Command -PSSnapin "Microsoft.Crm.PowerShell").count

If you want more information on any command, you can use the following:

Get-Help <cmdlet> –detailed

Unlike other products however, they neglected to type out an explanation of the command or give examples.  To get some explanations of the commands, you can refer to the newly updated CRM 2011 SDK.

So what can we do with these cmdlets?  Let’s look at some possibilities:

  • Refresh your test environment from your production environment.  You could use SQL PowerShell commands to backup and restore the database, then import the organization. For more on PowerShell for SQL, see TechNet
  • Create / Delete / Enable / Disable / Import CRM Organizations
  • Enable Tracing
  • Add / Remove Deployment Administrators
  • Set a new product key

Another reason to download the SDK is to get the sample PowerShell scripts that are included.  Here’s what provided:

Dynamics CRM 2011 SDK PowerShell Sample Scripts

I noticed 2 in particular, configure claims and configure IFD.  Nice!  I highly encourage you to get in there and dig in for yourself.  The PowerShell goodness only gets better from here!  Here are some more PowerShell resources:

Be sure to check out our recent webcast on CRM 2011 for Administrators on our C5 tube channel!