Created
September 23, 2016 11:38
-
-
Save Dan1el42/fbdef8a0be6a599c7b4c203d22283af2 to your computer and use it in GitHub Desktop.
Script example for post https://powershell.org/forums/topic/extract-information-from-log-file-using-powershell/
This file contains 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
$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