Microsoft Dynamics CRM 2011 – Using PowerShell to Manage


Windows PowerShell enables you to easily run deployment commands without writing code using the Deployment Web service. To execute commands, you must first configure Microsoft Dynamics CRM 2011 with Windows PowerShell. My blog describes how to do this and explains each of the supported commands.

Configure the Microsoft Dynamics CRM PowerShell cmdlets

Register the cmdlets

  • Log into the administrator account on your Microsoft Dynamics CRM server.
  • In a Windows PowerShell window, enter the following command:

Windows PowerShell: Add-PSSnapin Microsoft.Crm.PowerShell
This command adds the Microsoft Dynamics CRM Windows PowerShell snap-in to the current session. The snap-in is registered during installation and setup of the Microsoft Dynamics CRM server.

Supported PowerShell cmdlets

The following lists the cmdlets available for use with Windows PowerShell.

Cmdlet: Disable-CrmServer
Description: Disables the specified Microsoft Dynamics CRM server.

Cmdlet: Disable-CrmOrganization
Description: Disables the specified Microsoft Dynamics CRM organization.

Cmdlet: Edit-CrmOrganization
Description: Edits properties of the specified Microsoft Dynamics CRM organization.

Cmdlet: Enable-CrmServer
Description: Enables the specified Microsoft Dynamics CRM server.

Cmdlet: Enable-CrmOrganization
Description: Enables the specified Microsoft Dynamics CRM organization.

Cmdlet: Get-CrmOrganization
Description: Retrieves one or all of the organizations in the deployment of Microsoft Dynamics CRM.

Cmdlet: Get-CrmOperationStatus
Description: Retrieves the status on asynchronous operations sitting in the deferred operation queue for Microsoft Dynamics CRM.

Cmdlet: Get-CrmSetting
Description: Retrieves a Microsoft Dynamics CRM deployment setting object.

Cmdlet: Get-CrmServer
Description: Retrieves a server object for one or all Microsoft Dynamics CRM servers in a deployment.

Cmdlet: Get-CrmLicenseProperty
Description: Retrieves the license properties object for Microsoft Dynamics CRM.

Cmdlet: Get-CrmAdvancedSetting
Description: Gets an advanced setting value for Microsoft Dynamics CRM. The metadata specify that the setting is readable in order to retrieve the specified value.

Cmdlet: Get-CrmAccessLicense
Description: Retrieves the server licensing and CAL licensing information for the deployment of Microsoft Dynamics CRM.

Cmdlet: Get-CrmDeploymentAdministrator
Description: Retrieves the deployment administrators for the Microsoft Dynamics CRM deployment.

Cmdlet: Get-CrmCertificate
Description: Retrieves the certificate information for Microsoft Dynamics CRM. The certificate object contains the public key of the service bus signing certificate.

Cmdlet: Import-CrmOrganization
Description: Initiates the process to import a Microsoft Dynamics CRM organization database into the deployment.

Cmdlet: New-CrmOrganization
Description: Initiates the process to create a new organization in the Microsoft Dynamics CRM deployment.

Cmdlet: New-CrmDeploymentAdministrator
Description: Creates a new deployment administrator for the Microsoft Dynamics CRM deployment.

Cmdlet: Remove-CrmOrganization
Description: Deletes the specified organization from the Microsoft Dynamics CRM deployment.

Cmdlet: Remove-CrmServer
Description: Deletes the specified server from the Microsoft Dynamics CRM deployment.

Cmdlet: Remove-CrmCertificate
Description: Removes the specified certificate from Microsoft Dynamics CRM.

Cmdlet: Remove-CrmDeploymentAdministrator
Description: Removes the specified deployment administrator from the Microsoft Dynamics CRM deployment.

Cmdlet: Set-CrmProductKey
Description: Sets the product key for the Microsoft Dynamics CRM deployment.

Cmdlet: Set-CrmSetting
Description: Sets the specified Microsoft Dynamics CRM deployment wide settings.

Cmdlet: Set-CrmAdvancedSetting
Description: Sets an advanced setting value for Microsoft Dynamics CRM. The metadata specify that the setting is writable in order to set the specified value.

Cmdlet: Set-CrmCertificate
Description: Creates a certificate record or sets the properties of an existing certificate record in the Microsoft Dynamics CRM configuration database.

Cmdlet: Update-CrmOrganization
Description: Updates the specified Microsoft Dynamics CRM organization with the latest software updates or upgrades the organization from Microsoft Dynamics CRM 4.0 to Microsoft Dynamics CRM 2011.

Example

The following example shows how to use Windows PowerShell to enable tracing. This pattern can be used for all settings.

Windows PowerShell: PS C:\Users\Administrator> Add-PSSnapin Microsoft.Crm.PowerShell

Windows PowerShell: PS C:\Users\Administrator> Get-CrmSetting TraceSettings

CallStack     : True
Categories    : *:Error
Directory     : c:\crmdrop\logs
Enabled       : False
FileSize      : 10
ExtensionData : System.Runtime.Serialization.ExtensionDataObject

Windows PowerShell: PS C:\Users\Administrator> $setting = Get-CrmSetting TraceSettings

Windows PowerShell: PS C:\Users\Administrator> $setting.Enabled=”True”

Windows PowerShell: PS C:\Users\Administrator> Set-CrmSetting $setting

Windows PowerShell: PS C:\Users\Administrator> Get-CrmSetting TraceSettings

CallStack     : True
Categories    : *:Error
Directory     : c:\crmdrop\logs
Enabled       : True
FileSize      : 10
ExtensionData : System.Runtime.Serialization.ExtensionDataObject

My above blog is based on Microsoft’s Official information.

I hope this blog about ‘Microsoft Dynamics CRM 2011 – Using PowerShell to Manage’ was informative. Please feel free to leave your comments.

Post a comment or leave a trackback: Trackback URL.

Leave a comment