Okay, a recent interview I was asked a question and upon further thought I should have 1) answered differently 2) rant about it. The question was basically “with all of this powershell related answers you see things and figure out how to automate it?”
The simple answer is yes. However, with Powershell the answer is not that simple. Just referring at the Windows platform here.
Yes, Powershell has provided a much more powerful environment for scripting, tasks that would be considered automation. “If you repeat it, script it” is a great slogan I have seen and it’s very true. I have used bat files, kixtart, and then vbscript to assemble commands that I will use on a scheduled basis or just a tool to have for recurring tasks to address administration or resolve problems. Porting many of these routines to Powershell most certainly falls into the automation category.
What I believe is lost is just the power of the command line interface Powershell offers. Using a current situation, I can query a remote machine for specific values. I can call upon LDAP and WMI and can tweak my attempts. Yes, I could open compmgmt.msc to check what I am looking for but I find a shell environment is easier to work in personally. Using the data retrieved I can now perform steps necessary to resolve the issue, again all in the powershell command line interface. I test my changes and find that the steps taken do in fact resolve the issue. Now Automation does come in, with the steps now verified I can save them to a script for later use.
Another example is when I have been asked to make broad changes. Yes I could open my script editor of choice and write some code, but this is an impromptu request and I probably won’t be repeating the action. Being very generic; someone wants all accounts that end in X (in this case the naming convention would indicate that they are contractors) added to a group, using Powershell and the Quest AD cmdlets this can be down in a one-liner querying for all users matching criteria and piping that to the cmdlet to add group members. Yes there are other ways to perform the same operation, whether it be GUI or another console, but we are talking about Powershell and the assumption its for automation only.
Just my two cents.
Just my two cents.