Tuesday #PowerShell #PowerPost: Listing Perfmon Counters for MOSS helped by #REGEX

By | January 6, 2015

Yep, more from MOSS!

I’ve been exploring¬†ways I can use PowerShell to automate some tasks related to performance monitoring for MOSS and I wanted to turn the thinking into a quick post about using REGEX with PowerShell.

By no means am I a REGEX expert, in fact I’m whatever the opposite of a REGEX expert is, I’m terrified of it. ¬†That said, using it in basic ways is not the most complex thing you’ll do this year.

There are two REGEX constructs worth understanding here:

  • \.
    • . (the full stop) is the REGEX single character wildcard, so to use a literal “.” (as in .NET) you need to escape it using the backslash resulting in \.
  • .{1,}
    • This construct is to “repeat the last character no fewer than one time and up to any number of times” by prefixing it with “.”this is a method to apply a true wildcard to my REGEX, a little like using text* to mean “the word text followed by anything else”
    • If a number is added after the comma (such as {1,4}) this would signify “no fewer than 1 and no greater than 4”

Beyond that, it’s basic PowerShell using a Where clause matching against the REGEX pattern.

more to follow…

Leave a Reply

Your email address will not be published. Required fields are marked *