Tag Archives: About Topics

Learning PowerShell

Every few weeks or so, over the last 10 years or so, there is a new post somewhere, where somebody is asking about the best way to learn PowerShell. It has probably been a thing beginning in 2006. While I have not been evaluating this since then, I have noticed it long enough to feel confident in this statement. So confident that I have heard it for a long time, that I will remind everyone that I even wrote about it in 2016. In the time since the initial PowerShell launch, books have been written, videos have been recorded, new domains established, and web hosting purchased too. All of these have been done in the name of teaching other people PowerShell.

For all the posts I see where someone is looking for the best way to learn, I cannot recall hearing anyone mention the official PowerShell documentation. Okay, I saw a link somewhere recently, but it is not often mentioned. I have been spending some time there recently and it is undeniably thorough. It is well-written, explained clearly, and written for the newest of PowerShell users. The examples start with only the basic structures required. Not everyone out that does that, and it can be frustrating at times. I have been there, where I only want the simplest of examples from which to work. But some of the content out there is wildly complex and is obviously intended for an advanced audience. While I have always tried to write intermediate content with basic examples, not everyone has and that is fine.

Here is a link to the PowerShell About topics. Maybe spend a moment there right now. I dare you to challenge yourself to learn one new thing before you continue reading this post. On the linked page, scroll down until you find a topic that is not that familiar to you and read it — maybe even just a paragraph or two is all you will need. Stop when you learn something new. I will do the same and share what I learned…

For me, I scrolled down to about_Debuggers, where I learned that the Get-PSCallStack command is considered one of the Debugger Cmdlets. I know the command and have even written about it myself, but I never considered that it would be a debugging tool, although it makes perfect sense that it would. There is even documentation on all the, Microsoft-written commands. Here is where you can read more about Get-PSCallStack.

Here is my post on that command — I do not even mention debugging, so yes, I learned something new. It took less than five minutes. Hopefully, you really played along and learned something too. You are welcome to Tweet me what you learned and that way we may all learn something from it. Be careful though, learning and teaching people about PowerShell can be addicting.

Another challenge is that if you think you know a PowerShell topic, take a minute and read top to bottom on one of the About pages. You are probably going to learn something new. I was reading about the -replace operator recently and learned a few things I had never considered or known, simply because I have never needed to use it that way. Good to have read before, as someday I may be out there searching for a solution.

If you want to learn PowerShell, do not forget about the product’s own documentation; it has been written for you, by the people intimately involved in PowerShell. Like, it is their job. They create the resources that you can use to completely learn PowerShell — and it is all free. Maybe read two a day. Your job may provide some room for personal development, so read one to start the day and one to end it.

Changing direction a bit, the next thing I want to discuss is a script I wrote years ago. It is available on the PowerShell Gallery and it is called the Start-1to100Game3.0. If you are wondering, yes, it still pains me that I included the version of the script in the script’s name. Let that be a lesson.

This project was awesome. PowerShell chooses a number and then you select higher or lower until you guess the number. Simple concept, but well written. It kept totals, allowed continuous gameplay. I wrote about it many years ago, so read about it here if you want to know more.

You can download the poorly-named script using the below command.

Install-Script -Name Start-1to100Game3.0

By default, the script is going to be downloaded to the Scripts directory. On my computer, that is C:\Users\tommymaynard\Documents\PowerShell\Scripts. As you may know, you will have to dot source the script (as it is written as a function). This will allow you to run the function in the current scope. There is more information about this in about_Scripts. Here is the information you might be after on that page:

The dot sourcing feature lets you run a script in the current scope instead of in the script scope. When you run a script that is dot sourced, the commands in the script run as though you had typed them at the command prompt. The functions, variables, aliases, and drives that the script creates are created in the scope in which you are working. After the script runs, you can use the created items and access their values in your session.”

I could not have said it any better myself. So, keep in mind the About pages for learning PowerShell and enjoy a quick game of the 1 to 100 game — why not?

But, before we wrap up, what do these two things have in common!? Why have I placed these two topics — learning PowerShell using the About topics and my 1 to 100 script in the same post? Hopefully, I will be telling you soon. I am doing that thing where I am writing posts here before I write the PowerShell to back them up. So…, as long as I complete that project, some of this may actually make sense. And if it does not, at least we all got a reminder about the PowerShell About Topics and learned about an interactive game you, or your little one(s) — if you have those — can play. At this point, perhaps I will be back with more!