Enable the Developer Dashboard using the Object Model / Powershell


The SharePoint 2010 developer dashboard has three display levels (see SPDeveloperDashboardLevel Enumeration.):



  • Off (default): The dashboard is not displayed, and there is no UI element to turn it on

  • On: The dashboard is displayed, and there is no UI element to turn it off:

1



  • OnDemand: A UI element enables you to turn it on or off

2


There are a few ways to set the developer dashboard level.  One option is to use stsadm –o setproperty –pn developer-dashboard –pv “On”, but in this article, I’ll show you how to control the dashboard through the object model using PowerShell. 


To configure the dashboard, use the SPWebService.ContentService object to set properties on the SPDeveloperDashboardSettings class.  Here is the PowerShell script to set the level:


param($level = $(throw “level is required.  Level is On, Off or OnDemand”))

# import assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
[
void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint.Administration”)

# set the level
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$contentService.DeveloperDashboardSettings.DisplayLevel = ([Enum]::Parse([Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel], $level))
$contentService.DeveloperDashboardSettings.Update()

Write-Host (“Developer Dashboard Level: ” + $contentService.DeveloperDashboardSettings.DisplayLevel)


Here is a complimentary script to view the current settings:

# import assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
[
void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint.Administration”)

# get the level
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
Write-Host $contentService.DeveloperDashboardSettings.DisplayLevel

Comments (1)

  1. Andy says:

    Hello,

    thanks for writing this Powershell script. There is one thing, though. The code is not displayed completly, so a visitor can´t copy paste or even know how a line ends.

    It starts with param, but where is the part with function () ?

    At #Import assemblies in the 2nd line, it Ends with Admin, which should rather be Administration")

    I view the site with IE 10. Just a hint for you.

    Kind regards.

Skip to main content