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
2 Replies
- Anonymous隆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. - Lev_AnniCopper ContributorCan't believe nobody answered yet 馃槥