Last active
July 23, 2021 01:08
-
-
Save bill-long/8418d54eab0b64a95142950a2acc594f 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
# Note that this assumes we're running from the folder with the EWS logs in it. | |
# Choose the most recent 50 logs | |
Get-ChildItem *.log | Sort-Object LastWriteTime -Descending | Select-Object -First 50 | ForEach-Object { Import-Csv $_ } | Where-Object { $_.SoapAction -like "Resolve*"} | ForEach-Object { | |
# Produce a new object that only has the fields we care about | |
# One important part of this is we are converting the time and request times from strings into sortable values | |
[PSCustomObject]@{ | |
DateTime = [DateTime]::Parse($_.DateTime) | |
ClientIpAddress = $_.ClientIpAddress | |
AuthenticatedUser = $_.AuthenticatedUser | |
UserAgent = $_.UserAgent | |
SoapAction = $_.SoapAction | |
TotalRequestTime = [int]::Parse($_.TotalRequestTime) | |
} | |
} | Sort-Object TotalRequestTime -Descending | Export-Csv $home\desktop\ResolveNames.csv -NoTypeInformation |
To aggregate many files together:
$totalRequestTime = @{}
Get-ChildItem *.csv | % {
foreach ($line in (Import-Csv $_)) {
$totalRequestTime[$line.AuthenticatedUser] += [int]::Parse($line.TotalRequestTime)
}
}
$totalRequestTime.GetEnumerator() | Sort Value -Descending | Select -First 100 | ft -a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To produce the aggregate values: