Forum Discussion
Lev_Anni
Jul 29, 2024Copper Contributor
Can't add more than 60 performance counters for IIS at once!
Hi,
I have a lot of sites under IIS installation (4000-5000 sites). Don't tell me why 😕
I'm trying to add all of them at once in Performance counter to see which one is consuming high traffic but the windows mmc is unable to add them at once, I can pick up maximum 60 sites. Adding them this way is just nightmare.
Can anybody advice me how to add all of them at once using powershell script?
Thanks
- Lev_AnniCopper ContributorCan't believe nobody answered yet 😞
- Cletos85_hotmailcomBrass Contributor¡Entiendo lo frustrante que puede ser agregar tantos sitios manualmente! Puedes usar PowerShell para automatizar este proceso. Aquà tienes un script de PowerShell que te ayudará a agregar todos los sitios de IIS al contador de rendimiento:
```powershell
# Importar el módulo de WebAdministration
Import-Module WebAdministration
# Obtener todos los sitios de IIS
$sites = Get-Website
# Crear un contador de rendimiento para cada sitio
foreach ($site in $sites) {
$counter = New-Object System.Diagnostics.PerformanceCounter
$counter.CategoryName = "Web Service"
$counter.CounterName = "Current Connections"
$counter.InstanceName = $site.Name
$counter.ReadOnly = $true
$counter.NextValue()
}
```
Este script importa el módulo de WebAdministration, obtiene todos los sitios de IIS y crea un contador de rendimiento para cada sitio, configurándolo para monitorear las conexiones actuales.
Espero que esto te ayude a simplificar tu tarea.