I couldn’t find a simple way to turn the developer dashboard on and off via PowerShell - there’s a STSADM property for it, but who wants to use STSADM anymore? So here’s a function to change the setting quickly.

 

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
function Set-DevDashboard ( [string] $setting ) {
    $dashboardSetting = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings
    Write-Host "Setting Developer Dashboard DisplayLevel to $setting." -ForegroundColor Gray
    switch -exact ($setting) {
        "On" { 
            $dashboardSetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::On
         }
         "OnDemand" {
            $dashboardSetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::OnDemand
         }
         "Off" {
            $dashboardSetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::Off
         }
         Default {
            "Valid settings are On, OnDemand, or Off."
            break
         }
    }
    $dashboardSetting.Update()
}