Created
January 7, 2022 14:14
-
-
Save bill-long/43c0531b48ec09c0360ebf0e387621d2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function FindConnectionsWithoutSTARTTLS { | |
param( | |
$LocalEndpoint, | |
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] | |
[Alias('FullName')] | |
[string[]]$LogFile, | |
$Header = @('date-time', 'connector-id', 'session-id', 'sequence-number', 'local-endpoint', 'remote-endpoint', 'event', 'data', 'context') | |
) | |
begin { | |
$all = @{} | |
$startTLS = @{} | |
$localEndpointIp = $LocalEndpoint.Split(":")[0] | |
$files = New-Object System.Collections.ArrayList | |
} | |
process { | |
foreach ($file in $LogFile) { | |
[void]$files.Add($file) | |
} | |
} | |
end { | |
$filesDone = 0 | |
foreach ($file in $files) { | |
Write-Progress -Activity "Parsing log files" -Status "$filesDone / $($files.Count)" -PercentComplete ($filesDone * 100 / $files.Count) | |
Import-Csv $file -Header $Header | % { | |
if ($_.'local-endpoint' -eq $LocalEndpoint -and $_.'remote-endpoint' -notlike "$($localEndpointIp):*") { | |
$all[$_.'session-id'] = $_.'remote-endpoint' | |
if ($_.'data' -eq 'STARTTLS') { | |
$startTLS[$_.'session-id'] = 1 | |
} | |
} | |
} | |
$filesDone++ | |
} | |
$all.GetEnumerator() | ? { -not $startTLS.ContainsKey($_.Name) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
...