Knowledge: IIS Powershell Resource Script
Back
    Title*IIS Powershell Resource Script
    ManualInternal
    Created02/12/2025
    Detail

    Please note this script may take a good few seconds to return results:

    Import-Module WebAdministration
    $processes = Get-WmiObject Win32_PerfFormattedData_PerfProc_Process | Where-Object {$_.Name -like "w3wp*"}
    $apppools = & "$env:systemroot\system32\inetsrv\appcmd" list wp
    $coreCount = (Get-WmiObject Win32_ComputerSystem).NumberOfLogicalProcessors

    foreach ($proc in $processes) {
        $processId = $proc.IDProcess
        $apppool = ($apppools | Where-Object {$_ -match "WP `"$processId`""}) -replace '.*applicationPool:([^\)]+)\).*','$1'
        
        [PSCustomObject]@{
            ProcessID = $processId
            AppPoolName = $apppool
            "CPU(%)" = [math]::Round($proc.PercentProcessorTime / $coreCount, 2)
            "Memory(MB)" = [math]::Round($proc.WorkingSetPrivate/1MB,2)
        }
    }

    Privacy Policy
    Cookies help us to improve your user experience. By using this site you consent to cookies being stored on your device. Read more...
    View or hide all system messages