Rebuild Performance Counters

Posted by : on

Category : guides   operationsManager   powershell


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 suite my customers, and my own needs.

Email : [email protected]

Website : https://blakedrumm.com

About Blake Drumm

This is the personal technical blog for Blake Drumm. Currently primarily focused towards Microsoft System Center Enterprise Management Products. I am an Microsoft Support Engineer on the System Center North America Support Team. I am new to blogging. July 6th, 2021 marks my first day as a Microsoft FTE converting from a contractor. I had been working as a contractor since January 2020. Continue to check back for new posts or tips. I like to continually update this page as time permits.

Follow @blakedrumm
Useful Links