@@ -273,7 +273,9 @@ function GetHTTPRequestInformation
273273 [System.Management.Automation.Runspaces.PSSession ]$Session )
274274
275275 # Retreive 403 (Request) and 404 (Response) events along with corresponding 510's from security log
276- $RequestAndResponseEvents = Get403And404Events - CorrID $CorrID - Session $Session
276+ $RequestAndResponseEvents = @ ()
277+ $RequestAndResponseEvents += Get403And404Events - CorrID $CorrID - Session $Session
278+
277279 $HeaderEvents = @ ()
278280 foreach ($Event in $RequestAndResponseEvents )
279281 {
@@ -289,6 +291,7 @@ function GetHTTPRequestInformation
289291 {
290292 $CurrentID = $RequestAndResponseEvents [$I ].ID
291293
294+
292295 if ($CurrentID -eq 403 )
293296 {
294297 $HeaderObject.QueryString = $RequestAndResponseEvents [$I ].RemoteProperties[4 ] + $RequestAndResponseEvents [$I ].RemoteProperties[5 ] + $RequestAndResponseEvents [$I ].RemoteProperties[6 ]
@@ -308,7 +311,7 @@ function GetHTTPRequestInformation
308311 $HeaderObject = CreateHeaderObject # Clear object for next iteration of loop
309312 }
310313
311- if (($I % 2 -eq 0 -and $CurrentID -eq 404 ) -or ($I % 2 -eq 1 -and $CurrentID -eq 403 ))
314+ if (($I % 2 -eq 0 -and $CurrentID -eq 404 ) -or ($I % 2 -eq 1 -and $CurrentID -eq 403 ) -or ( $CurrentID -eq 403 -and $I -eq $RequestAndResponseEvents .length - 1 ) )
312315 {
313316 # Expecting each 403 to be followed by a 404. Each 403 should have an even index and each 404 should have an odd index in the list.
314317 Write-Warning " Unable to match request and response headers"
@@ -382,7 +385,7 @@ function Write-ADFSEventsSummary
382385 $row.CorrelationID = $Event.CorrelationID
383386 $row.Machine = $Event.MachineName
384387 $row.Log = $Event.LogName
385- $row.Level = $Event.LevelDisplayName
388+ $row.Level = $Event.LevelDisplayName
386389
387390 # Add the row to the table
388391 $table.Rows.Add ($row )
@@ -496,6 +499,11 @@ function Get-ADFSEvents
496499 foreach ($Event in $Events )
497500 {
498501 $ID = [string ] $Event.CorrelationID
502+
503+ if ($CorrelationID -ne " " -and $CorrelationID -ne $ID )
504+ {
505+ continue # Unrelated event mentioned correlation id in data blob
506+ }
499507
500508 if (! [string ]::IsNullOrEmpty($ID ) -and $HashTable.Contains ($ID )) # Add event to exisiting list
501509 {
@@ -545,4 +553,4 @@ function Get-ADFSEvents
545553
546554}
547555Export-ModuleMember - Function Get-ADFSEvents
548- Export-ModuleMember - Function Write-ADFSEventsSummary
556+ Export-ModuleMember - Function Write-ADFSEventsSummary
0 commit comments