Make your job easier with PowerShell
Benefits of Scripting
PowerShell, in many ways, can help make your life and job significantly easier. I started my job as part time tech support for a local community college. My immediate boss was the only full time IT staff on our campus. Besides him, there was myself and one other part time staff member. Between the three of us, we supported all of the faculty, staff, classrooms, A/V equipment, ITV equipment, and certain student needs. It was quite challenging to keep up with day-to-day needs for every user and maintain ongoing projects. When I first started, we were doing everything by hand. Updating computer labs that total up to about 100 computers would take weeks with full attention dedicated to doing nothing but updates. During that time updating a single machine would look something like this:
- Unlock the computer (We use SmartShield to keep them in a locked state)
- Log in to the Administrator account
- Check for updates to these software packages
- Google Chrome
- Mozilla FireFox
- Adobe Reader
- VLC
- Microsoft Office
- Check for Windows Updates
Note: Some of these software packages have been implemented now through Group Policy, but since this post is about PowerShell we will only be focusing on that.
Usually when doing these updates, we would be able to maybe focus on 3 at a time. Doing the software updates, by the time we started one, we could reach over and start a second or third computer before it would finish. We would do this for all of these computers. It was extremely time consuming and was not good for us physically either. There was not enough wait time to sit down so we would be hunched over each machine to start the process.
Work Smarter, Not Harder
I took over as the IT Coordinator back in May of 2016. We experienced a turnover of employees and with the previous Coordinator moving away and the other part-time staff member getting a new job, I was the only IT member on campus. My first week in this position I was spending most of my time preparing new computers for production and trying to keep up with updates. I knew there had to be a better way. Enter PowerShell. At this time, I had no experience with console but I knew this was the answer I'd been looking for.
Now, I will mention before going forward that I did not have any guidance as far as best practices, terminology, or the extent of what PowerShell was capable of. I entered this thinking it was a more modern version of the command prompt.
I started searching the internet with very specific search terms for what I was trying to accomplish. I wanted a way to make the computers set themselves up so I could focus my time somewhere else. I remember the first commandlet I learned was Add-Computer. I forced myself to use PowerShell for any task that I could think of even if it took longer. So, when preparing these new computers I started using the line Add-Computer -DomainName domain.edu -Credential domain\username. This started to get me a little more comfortable with the shell and I began diving in deeper. I did this every day, always trying to learn a new part of PowerShell before I left work. Not before long I had written my first script. Looking back at this, it was poorly done and and was definitely not the best way of performing these tasks. But hey, it was my first. I had successfully prepared a new computer using PowerShell. The way I did this was running a batch script to change the execution policy, open PowerShell, add the PC to the domain, create a logon script to execute and startup and then reboot. When the PC came back up, I had to log back in, but after that it would finish itself. It would install the needed software and then reboot. It had a lot of bugs though which I've since worked out. In fact, I no longer use that script as I've created an entirely new one that is much more efficient.
Learning PowerShell the Right Way
Now, there's no right or wrong way to learn PowerShell. But, for me, the right way was to actually get a book and read it. So, I bought Sams Teach Yourself PowerShell in 24 Hours. After reading through this book I began to understand some of the mistakes I'd made, terminology, more uses, and discovering that PowerShell had some insane power. My favorite part about PowerShell is its remoting capabilities. You can execute commands across many computers at once through PowerShell. Let me say this again: you can type a command on your computer that is ran across many computers. That is a game changer. Now, when working on these 100 or so computers, I do it from the comfort of my office and it takes minutes. Not days. Not hours. MINUTES.
So let's flash forward to the present. I have now written several modules and have really taken to heart the words of Don Jones and Jeffery Snover. Anything that I have to do more than once on a computer, I write something in PowerShell for it and save it to a module. A few of the modules that I have created will install specific software, changes specific registry settings, map printers, and gather inventory into a spreadsheet for me. Every week before the weekend, I unlock the lab computers and grab a remote session with them from my office. I type out my function that I wrote, a simple one liner, and hit enter. I now have roughly 100 computers checking for Windows updates, checking for software updates, and restarting. They will loop until there are no more updates to be found. Monday morning when I come back to the office, I simply lock the computers back up. This would have taken weeks without PowerShell.
If you are just entering the IT field or are working in a position that you maintain PCs, you need to know PowerShell. It is the future of Windows administration including server administration. Best of all, it makes your life simpler.
Beautiful post
liked and followed :)
I don't see that like anywhere though...