PowerShell: Why should I learn it? Where do I start?

Why should I learn PowerShell?

  • Microsoft, Linux, Unix, Solaris, Android, iOS – Operating Systems that run our planet.
  • Computers, Phones, Cameras, MediaPlayers, BlueRay players, Set top boxes, Alarm Systems, IoT – Some of the devices that we have that use these Operating Systems.
  • Shell, Bash, KornShell, Command Prompt, GUIs, PowerShell – Some of the interfaces that these devices have.
  • Batchfile, Shell Script, VisualBasic Script, PowerShell Script – Some of the powerful tools and methods that we can use to interact with not just a single device, but multiple, and at scale.

PowerShell is a TOOL. A tool that Microsoft has created that goes past the old ways of ‘scripts’ vs ‘GUIs’. The old ways was that you used one or the other. Usually the GUI for managing a single or a handful of systems, and a script to scale it out to multiple systems. PowerShell has changed this. PowerShell has been combined to manage both, usually without the admin even noticing! Exchange Admin Center, and even the newest Windows Admin Center that was released in April 2018 are all GUIs over PowerShell.

Why should you learn PowerShell? Because it’s here to stay as an AWESOME tool that doesn’t just worn on Windows, but also on Linux thanks to Microsoft Open Sourcing it. What does that mean? If you use Linux in your environment, you can install PowerShell on Linux and use the same commands to build scripts that will work on Linux systems as well as Windows systems. That’s 1 method that works cross-platform.

Where Do I Start?

You must start at the beginning. This may sound obvious, but it is often overlooked. You need to start by doing. Start small. VERY small. Something that you do every day on your own computer or on a remote system – Something as simple of kill a task, or find out if a task is running, gracefully shut it down, and if it’s not responding after 10 seconds, kill it. Start there. I started with Exchange 2007 management. To this day I still use a cmdlet.txt file that I copy/paste from for exchange management. I can write the commands from scratch, but it’s easier to copy/paste. I’ve turned some of them into functions but usually in the environments I’ve worked in, it’s usually one-offs as when you’ve got a well-running system there may be very little change.

Don’t use PowerShell on its own – use PowerShell ISE (Integrated Scripting Environment) where it will actually do a lot more for learning and developing. As you type, it will pop up suggestions and help you start learning PowerShell.

Below is a set of commands that will help you in so many scenarios it’s not funny. Jeffrey Snover did a really great job with PowerShell… I wish I could have met him at the MVP Summit back in March (It was my first MVP Summit, so I stayed on track – but I plan on going to the next MVP Summit in March 2019and I will take one of his sessions).

Get-Command *process* = this will look for any command with the word process in it and return it with all verbs you can use with it.

Get-Process | Get-Member = this will get what properties and methods that you can do with Get-Process

$(Get-Process).<PROPERTY> = using Get-Member above you can find that there is an AliasProperty of ‘Name’ to ‘ProcessName’ so you can use $(Get-Process).Name and it will give you all the names of all the processes it returns. The $() performs the command inside and returns the result object so that you can act on it (in this case, doing a property call of .Name)

$(Get-Process).Name.Split() = another round of .<METHOD/PROPERTY>

Two Last Take-Aways

  1. Always remember – Tab completion is your friend.
  2. Shortcuts and aliases are for one-off PowerShell lines (Find out by typing ‘alias’ in Powershell)… DON’T use them in your scripts – use the long form (eg. gci is short for Get-ChildItem…. With Tab-Completion writing it out long-hand is 2 extra characters and a tab key… and is MUCH more human readable and self-documenting).

Share the Post

About the Author

  • Next Post
  • Previous Post