<SharePoint:DeveloperDashboard runat="server" />
$svc=[Microsoft.SharePoint.Administration.SPWebService]::ContentService
$ddsetting=$svc.DeveloperDashboardSettings
$choiceOnDemand = New-Object System.Management.Automation.Host.ChoiceDescription `
"On &Demand","Dashboard can be toggled via icon near Welcome Menu"
$choiceOn = New-Object System.Management.Automation.Host.ChoiceDescription `
"&On","Dashboard is on for all pages"
$choiceOff = New-Object System.Management.Automation.Host.ChoiceDescription `
"O&ff","Dashboard is off"
$choices = [System.Management.Automation.Host.ChoiceDescription[]]($choiceOnDemand, $choiceOn, $choiceOff)
$caption = "Specify Developer Dashboard Setting for Farm"
$message = "Current the dashboard is: $($ddsetting.DisplayLevel)"
$result = $Host.UI.PromptForChoice($caption,$message,$choices,0)
switch ($result) {
0 { Write-Host 'Dashboard is now On Demand, toggle via icon near Welcome Menu'
$ddsetting.DisplayLevel=[Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::OnDemand
break
}
1 { Write-Host 'Dashboard is now On'
$ddsetting.DisplayLevel=[Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::On
break
}
2 { Write-Host "Dashboard is now Off"
$ddsetting.DisplayLevel=[Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::Off
break
}
default { throw "Developer Error"}
}
if ($result -ne 2) {
$ddsetting.TraceEnabled = $true
Write-Host @"
Trace was also enabled.
Note: v3 interface requires this on the master page for the Dashboard to render:
<SharePoint:DeveloperDashboard runat="server" />
"@
} else {
$ddsetting.TraceEnabled = $false;
Write-Host "Trace was also disabled."
}
$ddsetting.RequiredPermissions = 'EmptyMask'
$ddsetting.Update()
It also turns on trace, so it can be handy to find hard to debug problems.
In my case, it was helpful to find out why a delegate control wasn't rendering:
Tag(8e1n) Failed to create a user control from virtual path '/_controltemplates/CustomSearch.ascx': 'Microsoft.SharePoint.WebControls.SearchArea, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' is not allowed here because it does not extend class 'System.Web.UI.UserControl'.
Based on approach from Praveen Battula's blog