Tuesday, July 12, 2011

Crm 2011 Enabling Tracing with PowerShell


Tired of digging through the registry to enable tracing in Crm? Well, you can use PowerShell to enable/disable tracing in Crm 2011. Most of this script is from HTTP://SUPPORT.MICROSOFT.COM/KB/907490 but I had to make a few changes to get it to work. 
THE FOLLOWING POWERSHELL ENABLES TRACING:
Add-PSSnapin Microsoft.Crm.PowerShell
Get-CrmSetting TraceSettings
$setting = Get-CrmSetting TraceSettings
$setting.Enabled=1
Set-CrmSetting $setting
Get-CrmSetting TraceSettings
IISRESET
THE FOLLOWING POWERSHELL DISABLES TRACING:
Add-PSSnapin Microsoft.Crm.PowerShell
Get-CrmSetting TraceSettings
$setting = Get-CrmSetting TraceSettings
$setting.Enabled=0
Set-CrmSetting $setting
Get-CrmSetting TraceSettings
IISRESET
I changed the “True” and “False” from the KB article to 0 and 1 because “False” did not work.  I also added an IISRESET to the end, which is required to turn tracing on or off.
Executing the scripts in Server 2008 R2 is simple, just right click execute PowerShell. 
Enjoy!

No comments: