PowerShell & Text Manipulation
Scripting is the way forward for everything...but some things are so hard.
I’m a big, big fan of scripting for tasks. Anything that’s definable, repeatable, or requires bulk changes to stuff - why on earth would you do it manually? That’s hard work for hard work’s sake - and I’m not down with that.
I find it interesting that it’s almost seen as a bit of a black art, or voodoo. I work with very capable techs all the time - on some very large systems - and they of course use scripting, but they tend to use it in small batches. One command to do this, another set to do that etc. It’s successful, but....well, it’s not how I tend to do things.
If I have a definable task in front of me, and especially one that may need to be repeated - I’ll script it.
Anyways, scripting in the modern Microsoft age is PowerShell...except, when it isn’t.
I use to love VBScript - very flexible, easy to understand, very easy to get wrong (part of the fun), and utterly brilliant for free-text manipulation. By way of example, get a text file that has usernames in, email addresses, some random stuff, badly formatted phone numbers etc....then manipulating that in VB to give you a specific, defined format outcome is quite easy, and very effective.
Now, here’s the thing - I’m really struggling to do it in PowerShell. So, hence I’m opening this up to the Internet.... How do you do text manipulation in PowerShell?
Take this week for example, I had to do some relatively straight forward stuff - creating some groups, mail enabling, assigning Office365 permissions etc. The only way I could effectively bring this together in the timescale I had was to VBScript the initial input, and use VB to write the PowerShell Script to do the outcome after the initial manipulation of the input.
I so, so must be missing something. So come on Internet, educate me.
What’s the best way to dissect, manipulate, identify, and play with free text source files, so that I can feed them out to specific commands for explicit purposes....?