Tag Archives: 1 to 100 Game

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!

I am TechNet Gallery Years Old, Part III

Well, it is time for Part III of this series of posts. If you did not read the first one, or the second one, I would recommend starting with those. And now, it is time to cover the final four entries.

8. I love how the 1 to 100 game turned out. It is on the PowerShell Gallery and more information can be found on the post I wrote about it here, including what you need to know to get it on your computer. Here is an old screen capture of some gameplay. Just because it is the 1 to 100 game, does not mean you cannot choose your own numbers. This is the 1 to 3 game.

9. “Convert Alphanumeric String to the NATO Phonetic Alphabet Equivalent”

This script does not come with its own post, however, it was mentioned in this post about my Convert-TextToSpeech function. Essentially, it did exactly what this quote says from the post: “It takes a string made up of numbers and letters and writes it out in the Nato phonetic alphabet.” Since it does not have its own post to read, head straight to the GitHub Gist if you are interested. I have opted to take it for a spin this evening and included an image, too. You cannot tell, but including the Speak parameter will ensure the computer says the results out loud.

10. “Check Email Address Domain Against the Top-Level Domain (TLD) List from IANA”

Uh, this one was already covered in Part II. Weird it is on the list twice. That said, there were two different TechNet Gallery URLs. I attempted to use archive.org and the second of the two URLs was gone, gone. That means that what I wrote was 100% accurate: it must have been deleted. Either way, visit Part II if you want to learn more about this script, and you might.

11. “Map Drive to Drive Letter Using the Win32_DiskDrive Interface Type Property”

We have made it; it is the last one. This script does not have its own post here, but you can get the code from its Gist. The most I remember, at the moment, is that it was written for someone that may have needed help finding the drive letter of a USB drive — it has been a while. I may be totally wrong, but the person it was written for was appreciative. And really, it was kind of a monumental moment in my PowerShell community career. It was the first time I wrote something for someone else out there on the Internet. I am thinking that it may have been the beginning of my desire to learn and write about PowerShell here at tommymaynard.com.