Overview of Dynamics 365 Customer Engagement PowerShell

Dynamics 365 Customer Engagement PowerShell provides several modules each with a set of cmdlets that you can use to manage either Dynamics 365 Customer Engagement (online) or Dynamics 365 Customer Engagement (on-premises) instances.

The Dynamics 365 Customer Engagement PowerShell cmdlets are backward and forward compatible. For example, you can run the latest Dynamics 365 Customer Engagement (on-premises) Management PowerShell cmdlets against a Microsoft Dynamics CRM 2013 deployment. Similarly, you can use the original version of the Dynamics 365 Customer Engagement Connector PowerShell cmdlets against the current version of Dynamics 365 Customer Engagement (online).

The following modules and snapins are available.

Get started using the Microsoft.Xrm.OnlineManagementAPI module

This module works with Dynamics 365 (online).

You can install this module directly from the PowerShell Gallery.

  1. Start a PowerShell session.
  2. Enter the following cmdlet.
install-module Microsoft.Xrm.OnlineManagementAPI

Establish your credentials and connection

To establish your Dynamics 365 (online) credentials, run the following commands, where $user is your user account (UNC) and $password is your Office 365 tenant password.

$user = "admin@sfa.contoso.onmicrosoft.com"
$password = "password"
$cred = New-Object System.Management.Automation.PSCredential ($user, (ConvertTo-SecureString $password –ASPlainText –Force))

To save your Dynamics 365 (online) connection ApiUrl, run the following cmdlet, where $connectionhost is the root service url of your Dynamics 365 region. More information: Service URL

$connectionhost = "https://admin.services.crm.dynamics.com"

You can get help on any cmdlet. Get-Help cmdletname

For example, get help on the Backup-CrmInstance cmdlet Get-Help Backup-CrmInstance

Get started using the Dynamics 365 Customer Engagement Management (on-premises) PowerShell cmdlets

This module works with on-premises versions of Dynamics 365 and Microsoft Dynamics CRM.

These PowerShell cmdlets are installed on the computer when you install a Full Server role or when you install the Deployment Tools server role, if you’re installing individual server roles.

Register the cmdlets

  1. Sign in to the administrator account on your Microsoft Dynamics 365 server.
  2. Open a PowerShell command prompt.
  3. Enter the following command. Add-PSSnapin Microsoft.Crm.PowerShell

Provide your credentials to establish authentication

Running the following command will prompt you to type your user name and password to connect to the Dynamics 365 instance, and it will be stored in the $Cred variable that you can reuse in subsequent cmdlets. $Cred = Get-Credential

Now, run the cmdlets to manage your on-premises deployment. More information: Microsoft.Crm.PowerShell Module

Get started using the Dynamics 365 Customer Engagement Connector PowerShell cmdlets

This module works with both Dynamics 365 (online) and on-premises versions of Dynamics 365 and Microsoft Dynamics CRM.

Before you can use the PowerShell cmdlets, you have to register them.

  1. Download the Microsoft Dynamics 365 SDK package. Run the package file to extract the contents of the package. The PowerShell assembly (Microsoft.Xrm.Tooling.CrmConnector.Powershell.dll) and the script (RegisterXRMTooling.ps1) for registering the cmdlets are located in the \SDK\bin folder in the SDK.
  2. Start Windows PowerShell on your computer with elevated privileges (run as administrator).
  3. At the prompt, change your directory to the folder that contains the PowerShelldll file and the script for registering the cmdlets. For example: cd c:\SDK\bin
  4. Run the RegisterXRMTooling.ps1 script to register the XRM tooling PowerShell assembly, and install the Windows PowerShell snap-in. Type the following command, and press ENTER: .\RegisterXRMTooling.ps1
  5. Add the Windows PowerShell snap-in. This registers the Get-CrmConnection and Get-CrmOrganizations cmdlets. Add-PSSnapin Microsoft.Xrm.Tooling.Connector

Now, run the cmdlets you want. More information: Microsoft.Xrm.Tooling.CrmConnector.PowerShell Module

Get started using the Dynamics 365 Customer Engagement Package Deployment PowerShell cmdlets

This module works with both Dynamics 365 (online) and on-premises versions of Dynamics 365 and Microsoft Dynamics CRM.

Before you can use the PowerShell cmdlets, you have to register them.

  1. Download the Microsoft Dynamics 365 SDK package. Run the package file to extract the contents of the package. The PowerShell assembly (Microsoft.Xrm.Tooling.CrmConnector.Powershell.dll) and the script (RegisterXRMTooling.ps1) for registering the cmdlets are located in the \SDK\bin folder in the SDK.
  2. Start Windows PowerShell on your computer with elevated privileges (run as administrator).
  3. At the prompt in the Windows PowerShell window, change your directory to the Windows PowerShell folder under the PackageDeployer folder. In this case: cd c:\CRM\SDK\Tools\PackageDeployer\PowerShell
  4. Run the RegisterXRMTooling.ps1 script to register the Package Deployer Windows PowerShell assembly (dll), and install the Windows PowerShell snap-in for the Package Deployer tool. To do so, type the following command, and press ENTER: .\RegisterXRMTooling.ps1
  5. Add the Windows PowerShell snap-in. This registers the package deployment cmdlets. Add-PSSnapin Microsoft.Xrm.Tooling.PackageDeployment

Now, run the cmdlets you want. More information: Microsoft.Xrm.Tooling.PackageDeployment Module

Get started using the Dynamics 365 Customer Engagement Testing PowerShell cmdlets

These PowerShell cmdlets are used to define and execute tests on Common Data Service for Apps environments to detect regressions from solution or platform updates and upgrades. The results of the historical test runs can be accessed via API, and Power BI can be used to connect to the API to generate reports.

This module works with both Dynamics 365 for Customer Engagement apps (online). It does not work with Dynamics 365 for Customer Engagement (on-premises).

You can install this module directly from the PowerShell Gallery.

  1. Start a PowerShell session.
  2. Enter the following cmdlet.
install-module Microsoft.Xrm.Tooling.Testing
  1. To run any of the Microsoft.Xrm.Tooling.Testing cmdlets you must authenticate and provide the API connection URL. More information: Establish your credentials and connection

Test details

  • Test run suite. Defines the test suite (the test assemblies) and environment details against which the tests will run.
  • Test run. Represents a specific test run that executes manually or by an event trigger. Each run executes the entire test suite.
  • Test run case. A test case is part of a test run, representing the result of a specific test case run. Each test case is a test method found in the test suite assemblies.
  • Test run trigger. Defines a trigger event for which the test will be automatically run. The possible event triggers:
    • OrganizationDatabaseUpdate
    • OrganizationDatabaseUpgrade
    • OrganizationBitsUpdate
    • OrganizationPackageInstall
    • OrganizationPackageUninstall

Now, run the cmdlets you want. More information: Microsoft.Xrm.Tooling.Testing Module

Online Management API for Dynamics 365 Customer Engagement

Online Management API is a REST API that lets you create and manage Customer Engagement instances in your Office 365 tenant. Learn more