جستجو

  • 1698

You can list all active requests currently being processed by IIS with appcmd:

appcmd list requests

The reason I deliberately use the word "process" above is that IIS doesn't actually handle/terminate HTTP connections - the low-level nitty-gritty work of handling connections is offloaded to the OS-level HTTP driver (http.sys).

It may preempt request processing if a request can be served directly from the kernel-cache, and such a request will never show up in the request list. To see active connections to the machine, you'll either have to break out netstat:

$Connections = netstat -aon |findstr ":80 "

or use .NET to do something similar:

$GlobalIPProperties = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()
$Connections = $GlobalIPProperties.GetActiveTcpConnections() |Where-Object { $_.LocalEndpoint.Port -eq 80 }

On Windows 2012/8 or newer you can also use the Get-NetTCPConnection cmdlet:

$Connections = Get-NetTCPConnection -LocalPort 80 

The latter option is nice because you can easily interact with the objects in $Connections afterwards (ie. no string processing required). Such as grouping connections by IP for example:

# If using IPGlobalProperties
$DistinctIPCount = @($Connections |Group {$_.RemoteEndpoint.Address}).Count

# If using Get-NetTCPConnection
$DistinctIPCount = @($Connections |Group {$_.RemoteAddress}).Count
منبع