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 scripts to enable and disable tracing for Microsoft Dynamics CRM 2011.

The script is verified on the following Windows platforms:

  • Windows Server 2008 R2
  • Windows Server 2008

These are PowerShell scripts. You can copy the script into a text editor and save the file as a PowerShell file. PowerShell file has an extension of ps1.

I have saved these scripts as ‘EnableTracing.ps1′ and ‘DisableTracing.ps1′. To enable tracing run the script “EnableTracing.ps1″. To disable tracing run the script “DisableTracing.ps1″.

You can save these PowerShell scripts (files) to your server. Microsoft Dynamics CRM administrators and professionals can quickly enable or disable tracing by simply running these files.

The Script (File ‘EnableTracing.ps1′)

# —————————————-
# Script Definition: Script Definition: This script will enable the trace for Microsoft Dynamics CRM 2011.
# —————————————-
add-pssnapin Microsoft.CRM.Powershell
Get-CrmSetting TraceSettings
$setting = Get-CrmSetting TraceSettings
$setting.Enabled=”True”
Set-CrmSetting $setting
Get-CrmSetting TraceSettings
read-host ‘The trace is now enabled. Press enter key to close this window. . .’

The Script (File ‘DisableTracing.ps1′)

# —————————————-
# Script Definition: This script will disable the trace for Microsoft Dynamics CRM 2011.
# —————————————-
add-pssnapin Microsoft.CRM.Powershell
Get-CrmSetting TraceSettings
$setting = Get-CrmSetting TraceSettings
$setting.Enabled=”"
Set-CrmSetting $setting
Get-CrmSetting TraceSettings
read-host ‘The trace is now disabled. Press enter key to close this window. . .’

Note: Sometimes when you run a PowerShell file, for first time, it might open in Notepad. In order to open a PowerShell file with a PowerShell application, associate the file (with extension ps1) with C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

I hope this blog about ‘Microsoft Dynamics CRM 2011 – PowerShell scripts to enable and disable Tracing’ was informative. Please feel free to leave your comments.



See Also