Rebuild Performance Counters

Posted by : on

guides   operationsManager   powershell

Contents


How to Rebuild

Rebuild the Performance counters with the following Powershell Script, you can copy and paste the below script to a Powershell ISE Window running as Administrator:

Push-Location $PWD
$FirstPath = 'C:\Windows\System32'
$SecondPath = 'C:\Windows\SysWOW64'
cd $FirstPath
Write-Output '---------------------------------------------------------'
Write-Output "Recreating Performance Counters in: $FirstPath"
Write-Output ' - Running: lodctr /R'
lodctr /R
cd $SecondPath
Write-Output "`nRecreating Performance Counters in: $SecondPath"
Write-Output ' - Running: lodctr /R'
lodctr /R
Write-Output '---------------------------------------------------------'
Write-Output 'Resyncing the Performance Counters with Windows Management Instrumentation (WMI)'
Write-Output ' - Running: C:\Windows\System32\wbem\WinMgmt.exe /RESYNCPERF'
C:\Windows\System32\wbem\WinMgmt.exe /RESYNCPERF
Write-Output '---------------------------------------------------------'
Write-Output 'Restarting Service: Performance Logs & Alerts (pla)'
$error.Clear()
try
{
	Get-Service -Name "pla" | Restart-Service -ErrorAction Stop | Out-Null
}
catch
{
	Write-Warning "A Failure has occurred: `n$error"
}
$error.Clear()
Write-Output 'Restarting Service: Windows Management Instrumentation (winmgmt)'
try
{
	Get-Service -Name "winmgmt" | Restart-Service -Force -ErrorAction Stop | Out-Null
}
catch
{
	Write-Warning "A Failure has occurred: `n$error"
}
Pop-Location

Page Views


Share on:
About Blake Drumm
Blake Drumm

I like to collaborate and work on projects. My skills with Powershell allow me to quickly develop automated solutions to suit my customers, and my own needs.

Email :

Website :

About Blake Drumm

My name is Blake Drumm, I am working on the Azure Monitoring Enterprise Team with Microsoft. Currently working to update public documentation for System Center products and write troubleshooting guides to assist with fixing issues that may arise while using the products. I like to blog on Operations Manager and Azure Automation products, keep checking back for new posts. My goal is to post atleast once a month if possible.

Follow @blakedrumm
Useful Links