Pages

mandag 6. januar 2014

Windows Server: Rebuild all Performance Counters

You may need to rebuild a computers Performance Counters.

Before you do, check if any Counters are disabled. Use PoweShell to search the registry for all values with name 'Disable Performance Counters' under the Services key, like this:
$val='Disable Performance Counters'; gci HKLM:SYSTEM\CurrentControlSet\Services -rec -ea SilentlyContinue | % {if((gp -Path $_.PsPath) -match $val) {gp -Path $_.PsPath -Name $val}} | select PSPath,$val

To search for values with name 'Disable Performance Counters' under the Services key and return those with data greater than 0:
$val='Disable Performance Counters'; gci HKLM:SYSTEM\CurrentControlSet\Services -rec -ea SilentlyContinue | % {if((gp -Path $_.PsPath) -match $val) {if((gp -Path $_.PsPath -Name $val).$val -gt 0){$_}}}

You could turn on all disabled Counters like this (to actually do it you must remove the -WhatIf parameter):
$val='Disable Performance Counters'; gci HKLM:SYSTEM\CurrentControlSet\Services -rec -ea SilentlyContinue | % {if((gp -Path $_.PsPath) -match $val) {if((gp -Path $_.PsPath -Name $val).$val -gt 0){sp -Path $_.PsPath -Name $val -Value 0 -WhatIf}}}

To rebuild the Counters, open Command Prompt with Run as administrator and type:
cd c:\Windows\System32
lodctr /R
cd c:\Windows\SysWOW64
lodctr /R
WINMGMT.EXE /RESYNCPERF

You must stop and start the Performance Logs and Alerts service, open Command Prompt with Run as administrator and type:
net stop pla && net start pla

And the Windows Management Instrumentation service, open Command Prompt with Run as administrator and type:
net stop Winmgmt && net start Winmgmt