To activate the developer dashboard in SharePoint 2013, we can use some simple PowerShell cmdlets. To manipulate the setting in the web service of SharePoint, the following PowerShell script could be used. Save the file as DeveloperDashboard.ps1, then you can use it with the following parameters

.\DeveloperDashboard OnDemand

.\DeveloperDashboard On

.\DeveloperDashboard Off

Where the parameter are self-explaining. Enjoy!

param ([string] $mode)

$service = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$addsetting =$service.DeveloperDashboardSettings

switch ($mode.ToUpper())
{
    "ONDEMAND"
    {
        $addsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::OnDemand
        $addsetting.Update()

        Write-Host -ForegroundColor Green "Developer Dashboard set to $mode"
    }

    "ON"
    {
        $addsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::On
        $addsetting.Update()

        Write-Host -ForegroundColor Green "Developer Dashboard set to $mode"
    }

    "OFF"
    {
        $addsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::Off
        $addsetting.Update()

        Write-Host -ForegroundColor Green "Developer Dashboard set to $mode"
    }

    default
    {
        Write-Host -ForegroundColor Red "Unknow mode $mode"
    }
}

# end of script

 

Advertisements