Learn PowerShell: Episode 9, Debugging + Select + Looping
Channel: ABMedia
Date: 2021-12-04

In this 40-minute long episode, we're going to continue our exploration through PowerShell. This episode has a lot more practical stuff in it, getting the experience of putting together scripts for PowerShell!

And we also pray to our lord and saviour, "johm" ;)

This episode starts with debugging, as well as some recap on "if" statements from the last episode, which is quite a new tool we haven't seen, and definitely something helpful for learning PowerShell further and writing more complex scripts.

Then we start looking at "Select-Object", which is one of the most flexible commands in the entirety of PowerShell.

And finally, we learn about a brand-new concept, known as "looping", which is where we'll learn about "while" loops - a very important concept.

"If" Programming Tasks:

If (haha get it) you're not familiar with if statements from other languages, here are a few tasks you can try to practice your use of them:

1. Calculator -

  Make a simple calculator script that asks you to input two numbers and then asks you to choose either "+", "-", "*" or "/". Depending on which of those the user choses, it does that operation.

  Tip: You'll need an "if" to check whether they entered is a "+", and another to check if it's a "-" etc. And then write some code in each "if" to do the correct operation.

  Solution (with comments): https://abco.live/download/2021/ps1.html

2. String Length Comparer - 

  Make a program that gets you to enter in two strings, and then use if statements to compare the ".Length" of them and say which is longer

  Tip: You'll need one if to check if the first is longer, one to check if the second is longer, and one to check if they're the same.

  Solution (with comments): https://abco.live/download/2021/ps2.html

Chapters:

0:00 Debugging + Recap
4:10 elseif
8:38 Select-Object
12:44 Export one property to CSV 
16:40 Looping + Where
20:45 Repeated Input Script
25:23 The Ultimate Script (not really)

Thanks for watching my video, before are some general ABMedia links if you are interested:

Website ► https://abco.live/
Discord ► https://abco.live/discord

The Discord server is a place to chat with the creator of this video, as well as anyone who contributed to its development and has helped support ABWorld over the years.

A huge thank you goes to @ndumiphotos (on Instagram) for the graphics used in the intro.

#powershell #learnpowershell #programming