the same way that you can Toggle the Developer Dashboard using STSADM.exe, you can also toggle it using PowerShell. It is slightly more complicated, but works just as fine and it’s also faster than the STSADM command. Let’s have a look:
$service = [Microsoft.SharePoint.Administration.SPWebService]::ContentService $ddSettings =$service.DeveloperDashboardSettings $ddSettings.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::OnDemand $ddSettings.Update()
What it does, is retrieving the content web service, then retrieve the service’s dashboard developer settings and setting their display visibility level. It can be set to either of these:
[Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::On [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::Off [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::OnDemand
If you execute script, do it line by line or store them as a scripted .ps1 file before. There will be no success messages, but if you don’t get an error or warning from the PowerShell
Make sure you run these in a SharePoint Management Shell that you started with “Run as administrator”. Otherwise it will not work. Also, using the SharePoint Management Shell saves you from needing to add the SharePoint library using the Add-PSSnapin cmdlet. If you should decide to open just a “normal” PowerShell command interface, make sure to execute the following:
Then run the above mentioned script, it should work fine. Please make sure to test any scripts before running them in a production environment. As usual, I cannot take responsability for any damage caused by scripts on this page. They are provided as-is. Adaptations could be necessary to make it run successfully.
Best regards and stay tuned till the next time!
Martin (currently enjoying the sun in Calabria!)