Weekly Shell: RegEx and Switch
I recently needed to write a script that accepted domain credentials. The problem is that there are two ways of providing these in Windows: The old DOMAIN\USER way from NT, and the newer user@domain UPN format that Active Directory introduced. The code I was writing could use either, but needed
Weekly Shell: Select-String and Regular Expressions
So here's where last week's post on regular expressions came into a real-world scenario for me. I needed to comb through an IIS log file and find every IP address that was hitting a particular Web page on a Web site. Actually, I needed to comb through a bunch of
Weekly Shell: Fun with RegEx’s
I've had some fun working with regular expressions in PowerShell recently. Take this beauty: ^\\\\\w+(\\\w+)+ It's a UNC path. The ^ anchors the start of the string, making strings like "this\\Server\path" illegal; the double backslash ("\\\\" in the regex, because backslash is a special character and has to be escaped