Last active
November 1, 2018 20:23
-
-
Save nzbart/5546611 to your computer and use it in GitHub Desktop.
Get-WebRequestSummary returns a list of requests currently executing against IIS 8 (Windows 8 or Windows Server 2012).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -TypeDefinition @" | |
[System.FlagsAttribute] | |
public enum PipelineStateFlags | |
{ | |
Unknown = 0, | |
BeginRequest = 1, | |
AuthenticateRequest = 2, | |
AuthorizeRequest = 4, | |
ResolveRequestCache = 8, | |
MapRequestHandler = 16, | |
AcquireRequestState = 32, | |
PreExecuteRequestHandler = 64, | |
ExecuteRequestHandler = 128, | |
ReleaseRequestState = 256, | |
UpdateRequestCache = 512, | |
LogRequest = 1024, | |
EndRequest = 2048, | |
SendResponse = 536870912 | |
} | |
"@ | |
<# | |
.SYNOPSIS | |
Returns a summary of outstanding requests currently running against IIS. | |
.NOTES | |
Author: bart@ecargo.co.nz | |
#> | |
function Get-WebRequestSummary() { | |
Get-WebRequest | % { | |
$portString = ":" + $_.localPort.ToString(); | |
if($_.localPort -eq 80) { | |
$portString = "" | |
} | |
New-Object PSObject -Property ([ordered]@{ | |
Request = $_.verb + " " + $_.hostName + $portString + $_.url | |
ClientIpAddress = $_.clientIpAddress | |
TimeElapsed = [TimeSpan]::FromMilliseconds($_.timeElapsed) | |
PipelineState = [PipelineStateFlags]$_.pipeLineState | |
TimeInPipelineState = [TimeSpan]::FromMilliseconds($_.timeInState) | |
CurrentModule = $_.currentModule | |
TimeInCurrentModule = [TimeSpan]::FromMilliseconds($_.timeInCurrentModule) | |
}) | |
} | |
} | |
Export-ModuleMember Get-WebRequestSummary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment