Scripting Wife Comments on Beginner Event 5
Summary: The Scripting Wife reveals her impressions of 2013 Scripting Games Beginner Event 5.
This event was tough—at least for me. You see, the thing is that I can read text files, and I can get listings of text files. And these log files are just text, after all. The trouble is the part about finding IP addresses. That had me stumped. I tried using the filter with Get-Content, but I could not make it work for me. So in the end, I had to ask the Scripting Guy for help.
Lots of luck there. But what he told me was just enough to get me moving in the right direction. He said I need to use a regular expression to find the IP address in the log files. He told me to search the Hey, Scripting Guy! Blog for regular expression and IP address. So I did.
I did not find exactly what I needed; but then again, I guess I did. What I was looking for was a Regex pattern that defines an IP address. I actually found the pattern in an old Scripting Guy blog post from 2007—written in VBScript script. It does not matter, because it is the pattern I needed. Once I had the pattern, I needed to find a cmdlet that would accept a pattern, so I used Get-Command like this:
Get-Command -ParameterName pattern
Then I needed to look up Help about the cmdlet I found, and figure out how to give it the Regex pattern. When I did that, I got my matches, and then I reduced the matches to unique ones. That did it. Hope this helps you. It is actually pretty cool, and it can be done as a one-liner.