How many times have you worked with Regular Expressions and forgotten what expression denoted what? Oftentimes I need to search online to figure out what…
I seem to find my self turning to regular expressions more often these days, often to help out a fellow scripter in one of the many scripting forums I keep tabs on. I thought I'd take a moment and provide a brief explanation on how to use regular expressions in VBScript. First off, for those who don't know, a regular expression is a way of identifying or matching a string against a pattern. For example we all know that 172.16.100.200 looks like an IP address because of its pattern. The string firstname.lastname@example.org looks like an email address, again based on the pattern. A regular expression can be used identify strings based on a pattern.
I love that part of my job is helping people out in the forums as ScriptingAnswers.com. A recent post asked about finding out what network drives were mapped on a remote computer using PowerShell. The task sounded familiar so I poked around my script pile and found an old VBScript that used WMI and the Win32_NetworkConnection class. Great. Get-WMIObject to the rescue:
Get-WMIObject win32_networkconnection -computername Desk23
You even get a nicely formatted summary. But you me, I can't resist tinkering so I wrote a function that enhances this basic command I call Get-NetConnection