Scripts are great, right? PowerShell, with it's hooks into the .NET Framework, allows us to automate just about any task we want to do. Whether it's deleting some old files, monitoring Active Directory, provisioning new virtual machines and now even managing network switches, the only limitation we have is our time and knowledge. PowerShell can automate all kinds of stuff!
The complexity of the tasks we do in PowerShell vary widely. Some use the PowerShell console exclusively just to do simple tasks they used to do with cmd.exe. Shame! Others decide to write some simple scripts that delete files older than a specific date or perhaps do a WMI inventory of the PCs on their network.
Automation is More than Saving Time
The crazy, passionate PowerShell admin geeks, on the other hand, take it to another level all together.
All this automation is great, right?
PowerShell is helping us IT pros save tons of time and know the task will be done the same all the time, every time.
While you're saving all this time do you ever stop to realize that writing a script forces you to learn that task inside and out? Even if you merely go through the motions of writing a script without even writing anything you'll come out knowing a ton more about the actual task!
Have you ever decided to sit down and script some process that you think will take five minutes and end up taking five hours? It's not because you wanted to add more bells and whistles to the script but you honestly didn't understand the task well enough in the first place? �Be honest!
I've done this countless times.
I've found that scripting not only has helped me save time and standardize but it's also helped me thoroughly understand every task I automate.
I'm not talking about the one-liners like
Get-Content sometextfile.txt where you're just viewing the contents. I'm talking about actual scripts; the scripts that you pour your heart and soul into sometimes off and on for days. �I'm talking about 500-line scripts or PowerShell modules; the stuff that makes you think!
A Personal Story
I love examples and I seem to always have a bunch in my head at all times so here's one from a personal experience.
If you're an avid reader of this blog, you might have seen the articles I've posted about Active Directory-integrated DNS records. I was having a hell of a time tracking down some issues of disappearing DNS records at a client site.
Throughout this process I've had to learn a lot of how DNS integrates with Active Directory because I've scripted nearly everything I've done.
Let me give you an example of setting permissions on an AD-integrated DNS record. You may say you know how to do that, right? Just go into the DNS MMC console, right click on a record, click on the Security tab and do whatever you need to do. �Sure, that's fine but do you know what your action is actually doing there?
You might not.
You're not just "setting permissions" first of all. You're actually setting a new ACE on an Active Directory object that's in the objectClass dnsNode. �Also, this dnsNode object can either be located in the Forest or DNS zones naming context depending on how you set the replication scope up.
Also, do you know that you can also find these DNS records via
Get-AdObject? �The rabbit hole goes deep.
Do you understand where I'm going with this?
Simply using a GUI tool that some developer gives you to abstract away what you're actually doing is nice but to truly understand how something works you've got to go deeper into the code. It's not always necessary to do but, for me, scripting something, even if I don't really need to, makes me understand a topic much, much better.
The next time you run into a problem you can't figure out pretend like you're going to write a PowerShell script to automate it. �I guarantee you that just getting into that mindset will open up your mind on a different level and allow you to solve problems you never thought you could.
Join the Jar Tippers on Patreon
It takes a lot of time to write detailed blog posts like this one. In a single-income family, this blog is one way I depend on to keep the lights on. I'd be eternally grateful if you could become a Patreon patron today!Become a Patron!
Subscribe to Adam the Automator
Get the latest posts delivered right to your inbox