Skip to content

Instantly share code, notes, and snippets.

@nzbart
Last active November 1, 2018 20:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nzbart/5546611 to your computer and use it in GitHub Desktop.
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).
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