Forum Discussion

Lev_Anni's avatar
Lev_Anni
Copper Contributor
Jul 29, 2024

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's avatar
    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.

Resources