Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Dan1el42/fbdef8a0be6a599c7b4c203d22283af2 to your computer and use it in GitHub Desktop.
Save Dan1el42/fbdef8a0be6a599c7b4c203d22283af2 to your computer and use it in GitHub Desktop.
$logFileContent = Get-Content -Path C:\My\Forum\mail.log -Raw
$regExMatches = [regex]::Matches($logFileContent, '(?<timestamp>[0-9/: ]+)\tUser (?<email>[a-z0-9@.]+) logged on')
$items = $regExMatches | ForEach-Object {
[PSCustomObject]@{
timestamp = [DateTime]$_.Groups['timestamp'].value
email = $_.Groups['email'].Value
}
}
$items | Group-Object -Property email | Select-Object -Property Name, Count | Sort-Object -Property Count -Descending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment