Created
May 28, 2013 18:08
-
-
Save janegilring/5664784 to your computer and use it in GitHub Desktop.
Entry from the 2013 Scripting Games Beginner Event 5, reviewed at blog.powershell.no
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
<# | |
.SYNOPSIS | |
Gets the Unique IP Information from a directory of *.log files. | |
.DESCRIPTION | |
This script was written for the Event 5 Beginners Track in the 2013 Scripting Games. | |
It will look through IIS logs in a directory and all sub directories and pull out a | |
list of unique ip's. | |
.PARAMETER PathToLogs | |
Path to the Log files (Example C:\Temp\LogFiles\) | |
.EXAMPLE | |
.\GetUniqueIPs.ps1 -PathToLogs C:\Temp\LogFiles | |
#> | |
param( | |
[Parameter(Mandatory=$True)][string]$PathtoLogs | |
) | |
get-childitem $PathtoLogs -Recurse -Include *.Log | | |
select-string -Pattern ‘\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b’ -allmatches | | |
ForEach {$_.Matches} | | |
Foreach {$_.Value} | | |
Select-Object -Unique |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment