Turn on the Developer Dashboard via PowerShell

I found some outdated information for the SharePoint snap-in for PowerShell.  The cmdlet to enable and disable the developer dashboard has been deprecated. To use powershell, we ultimately need to use the Object Model.

To view the answer, just scroll to the bottom!

In particular, we’ll use this Library::Object     
[Microsoft.SharePoint.Administration.SPWebService]::
ContentService.DeveloperDashboardSettings;  The original documentation said to use this:     

PS C:\Users\svc_sp_admin> Set-SPFarm -DeveloperDashboardEnabled      

The term 'Set-SPFarm' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling
of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:11
+ Set-SPFarm <<<<  -DeveloperDashboardEnabled
    + CategoryInfo          : ObjectNotFound: (Set-SPFarm:String) [], CommandN
   otFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

        

So I tried this:       

PS C:\Users\svc_sp_admin> Set-SPFarmConfig -DeveloperDashboardEnabled
Set-SPFarmConfig : A parameter cannot be found that matches parameter name 'DeveloperDashboardEnabled'.
At line:1 char:44
+ Set-SPFarmConfig -DeveloperDashboardEnabled <<<<    + CategoryInfo : InvalidArgument: (:)
[Set-SPFarmConfig], ParameterBindingException + FullyQualifiedErrorId :
NamedParameterNotFound,Microsoft.SharePoint.PowerShell.SPCmdletSetFarmConfig

       

Finally, I was told by a certain ADMIN to use the OBJECT MODEL. LOL. He was right, though. 🙂 He’s a good admin and developer wannabe.       

PS C:\Users\svc_sp_admin>
[Microsoft.SharePoint.Administration.SPWebService]::
ContentService.DeveloperDashboardSettings;
       

DisplayLevel                 : Off
TraceEnabled                 : False
RequiredPermissions          : AddAndCustomizePages
MaximumSQLQueriesToTrack     : 50
MaximumCriticalEventsToTrack : 50
AdditionalEventsToTrack      : {}
Name                         :
TypeName                     : Microsoft.SharePoint.Administration.SPDeveloperD
                               ashboardSettings
DisplayName                  :
Id                           : d72a704a-81a1-429f-8c4d-5372e5524b42
Status                       : Online
Parent                       : SPWebService
Version                      : -1
Properties                   : {}
Farm                         : SPFarm
UpgradedPersistedProperties  :

    

   And while I appreciate the blogs out there that teach Admins how to code, let’s face it, even developers don’t instanciate objects when they don’t need them. So, here’s the long way that some suggest:     

    

$val = "On";
$cs = [Microsoft.SharePoint.Administration.SPWebService]::ContentService;
$cs.DeveloperDashboardSettings.DisplayLevel = ([Enum]::Parse([Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel], $val));
Write-Host ("Developer Dashboard Level: " + $cs.DeveloperDashboardSettings.DisplayLevel)

Let’s consolidate that:    

    

$cs = [Microsoft.SharePoint.Administration.SPWebService]::ContentService;
$cs.DeveloperDashboardSettings.DisplayLevel = ([Enum]::Parse([Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel], “On”));
Write-Host ("Developer Dashboard Level: " + $cs.DeveloperDashboardSettings.DisplayLevel)

OK. One more consolidation. Use this single command to set the developer dashboard.    

[Microsoft.SharePoint.Administration.SPWebService]::
ContentService.DeveloperDashboardSettings.DisplayLevel =
([Enum]::
Parse([Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel], 
“On”));

It’s very long, so I suggest copy and paste. I had to include RETURN breaks as it scrolled off the page.  

And to view it, use       

[Microsoft.SharePoint.Administration.SPWebService]::
ContentService.DeveloperDashboardSettings

Happy SharePointing!

Advertisements

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: