2013 Scripting Games: Beginner Event 5

Doctor Scripto

Summary: Scripting Games Beginner Event 5: Dr. Scripto needs to find client IP addresses from IIS logs. Microsoft Scripting Guy, Ed Wilson, is here. Today is the release of Event 5 for the 2013 Scripting Games. Remember that they are being run and hosted at www.powershell.org. You will need to go to that webpage to submit your entry.

The Logfile Labyrinth

Dr. Scripto finds himself in possession of a bunch of IIS log files. (It is much like the one at http://morelunches.com/files/powershell3/LogFiles.zip, if you need one to practice with.) He’s keeping all of the log files in C:ReportingLogFiles, and he’s left the log files with their default file names, which he’s given a .log file name extension. All of the files are for a single website, on a single web server. He’d like you to simply scan through each file, and generate a list of each unique client IP address that’s been used to access the website. No IP address should appear more than once in your output, and you don’t need to sort the output in any way. As described in IIS Log File Example, the client IP address is the first item in each log file entry. Regardless of the addresses found in the sample file, you should assume that any legal IP address may appear in the files that Dr. Scripto needs to scan. Your command should scan all of the files in the folder (and the folder doesn’t contain any other kind of file) and produce a single set of results. If an IP address appears in multiple log files (it’s likely that will be the case), your final output should still only list that IP address one time. Dr. Scripto is getting a little tired, so he’s asked you to keep your command as short and concise as possible, although you’re welcome to use full command names and full parameter names to make things easy to read. I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy