My Powershell Journey

My Powershell Journey
Page content

The Road to Automation

Tl;dr: CS50 for the logic, Powershell in a Month of Lunches for syntax, Powershell for Sysadmins for Infrastructure, reading a lot of other scripts, writing a lot of scripts yourself.

In more detail, I’ve started my Powershell journey in 2017 when I got back into IT starting again all the way from the bottom (1st line).

I already had experience with writing simple batch and bash scripts due to having automated stuff for customers’ PCs deployments and myself in the past and I had already started Harvard’s CS50 multiple times but never finished it.

But Powershell? That was new for me.

Well, after doing a few weeks of answering calls, and getting used to how things worked in Enterprise IT nearly half a decade after I had last worked in the field, I started getting annoyed by the constant repetitive clicking so I decided to look into how to automate those repetitive actions.

Initially I started using simple cmd commands, then wrote simple batch files, then more complex batch files (the turning point being during the migration to O365 where I cut down the “Reset user profile, delete Outlook folder in %localappdata%, clear credentials” process down from a few minutes to a few seconds) and then I discovered Powershell.

Initially it was just simple commands as I was trying to understand its logic, but when I was moved up to 2nd line on another project I realized that I could go much MUCH deeper and started writing more complex scripts. At that time I wasn’t aware of books teaching proper Powershell so the code was predictably not the best, but due to reading A LOT of other peoples’ code I was exposed to many different ways of solving the same issues, and that allowed me to really understand the language better.

Many dozens of scripts later I finally stumbled upon what’s widely considered the Powershell Bible: Manning’s “Learn Powershell in a Month of Lunches” and that was truly a game changer.

Not only it allowed me to fix many of the mistakes I was making (but that Powershell accepted because it’s way too forgiving at times), but it taught me critical information about the basics of the how the language worked, which greatly increased my ability to efficiently use it for problem solving.

A few months and many thousands of lines of code later I was moved to a project where my main role WAS automation, which triggered me looking for additional knowledge on how to write better Powershell code and that brought me to “PowerShell for Sysadmins: Workflow Automation Made Easy” by Adam Bertram.

While it wasn’t as much of a paradigm change as the first book, it had one big advantage: it was focused on managing and automate infrastructure, which was my main focus at the time, and it greatly improved the readability, cleanliness and error handling of my code.

And that is kinda it. After that I kept writing code, reading code and practicing code, until recently where my focus moved more towards Security and Architecture.

Though even in those fields, especially in Security, I’m still using Powershell frequently!


P.S: If you want to see some examples of my Powershell code see here: