This project is read-only.

Using the xRM CI Framework and Windows PowerShell you can easily extend the build and automate the deployment of your CRM Solutions

PowerShell allows you to automate various processes by scripting the tasks that are normally performed manually on servers and applications. PowerShell is built on the .NET Framework. That allows you to use any .NET library in your scripts and allows you to work with and manipulate standard .NET objects in a friendly syntax that is close to C# and JavaScript.

Microsoft provides lots of PowerShell commands “cmdlets” that allow you to manage Windows Servers (IIS, File System, Registry) and applications such as Microsoft Office.

The Dynamics CRM SDK includes some PowerShell cmdlets but these are limited to managing CRM organizations through the Deployment Web Service. Check this post for more information about these.

The xRM CI Framework provides you with PowerShell “cmdlets” to allow you to script some of the task that are done manually during the build and/or deployment of Dynamics CRM Solutions.

Using the custom “cmdlets” you are able to assemble a script that can be triggered during your TFS build process or executed on demand from your desktop or other automation tools.


First HelloWorld example “WhoAmIRequest”

  1. Once you downloaded and extracted the xRM CI Framework, all the assemblies you need to start using the “cmdlets” will be found in the “PowerShell” folder. In this case I have extracted the framework to “C:\Temp”. You should be able to see the below in the “PowerShell” folder. Note this also contains all the sample scripts and scripts required by the TFS Build template.


  2. Run Windows PowerShell Shell which will start “powershell.exe” and browse to the “PowerShell” folder of the framework


  3. The first thing you need to is load the framework PowerShell Module using the Import-Module cmdlet. This will make the Dynamics CRM 2013 cmdlets available for you to use.


  4. Let’s declare a connection string that we can use to connect to Dynamics CRM. This has to follow this format described in here.


  5. Now let’s use the first Cmdlet “Select-WhoAmI”. This return an object of type “WhoAmIResponse”. You just need to pass it the connection string we constructed above. Note how we can interact with the object returned to access the properties. We could also call any available methods.

  6. You could also invoke the Cmdlet with the –Verbose switch so it can give more information as it is executing.


  7. You can use Get-Command Cmdlet to get a list of Cmdlets available in the framework


  8. You can then use the Get-Help Cmdlet to find parameters required by each Cmdlet.
    Check the sample scripts to see how some of these Cmdlets are used for build and deployment automation.
    You can also take a look at the source code if you need to find out more details.


  9. Now you should be ready to start using your first Dynamics CRM PowerShell Script

Last edited Aug 5, 2014 at 11:19 PM by waelhamze, version 9