Freigeben über


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

  • Anonymous
    May 16, 2013
    The comment has been removed