Powershell: RegEx

Lately I've been doing RegEx replacement with powershell instead of Perl because it has turned out to be so intuitive.
I've also had a bit of fun doing various powershell one-liners from the command line for stuff I just need to do quickly and probably don't need again. For example:

Powershell -command $allservers = get-content allservers.txt; $allservers -Replace ‘\.corp\.domain\.com’, ‘’
the above executes powershell and runs a command that reads in a file of servers' dns names and then writes to the screen the list without the domain part of their name.
Also, I often use TextPad ( to use a more complicated RegEx against a file.

No comments: