How to Learn PowerShell in 2022
PowerShell endures as an automated task system used by countless IT professionals. Here are tips on how to learn PowerShell -- plus, resources to jumpstart your education.
April 7, 2022
Learning Microsoft’s PowerShell program can be a daunting process, particularly for those who tend to avoid command line environments. Even so, there are tricks you can use to make the learning process easier.
In this article, I’ll provide tips on how to learn PowerShell so you can get up and running quickly.
Video-based Tutorials
Arguably, the easiest way to learn PowerShell is through video-based education. I recently finished recording a 12-hour PowerShell course that will launch soon. However, there are plenty of other courses available.
If you prefer the free option, check out YouTube. YouTube offers lots of videos on the subject.
Learn the Basic Syntax
Putting aside video-based tutorials, I would recommend starting out with PowerShell’s basic command structure. While there are thousands of PowerShell cmdlets, nearly all of them adhere to the same basic syntax rules. Once you learn how those syntax rules work, you can figure out nearly any cmdlet.
Incidentally, Microsoft refers to the native PowerShell commands as cmdlets (pronounced “command-lets”). Cmdlets consist of two words: a verb and a noun. The verb and noun have a dash in between them. For example: Copy-Item.
PowerShell cmdlets tend to use familiar, everyday language because Microsoft wanted to make it relatively easy to figure out which cmdlet to use in a given situation.
Here’s an example of how to use a PowerShell cmdlet. Suppose for a moment that you wanted to see a list of the processes running on your computer. The PowerShell cmdlet that you would use is Get-Process, shown in Figure 1. In this case, Get is the verb and Process is the noun.
Learn powerShell 1
Figure 1. The Get-Process cmdlet retrieves a list of system processes.
So, with that in mind, what command might you use to display a list of the services running on your computer? The cmdlet that would be used is Get-Service.
Notice that both the Get-Process and Get-Service cmdlets use the word “Get.” PowerShell cmdlets that include the Get verb are always used to retrieve some piece of information.
Just as verbs such as Get play a consistent role across a variety of cmdlets, so too do nouns. I showed that Get-Service retrieves a list of services, but what cmdlet might you use to shut down a service? The cmdlet would be Stop-Service (you would also have to supply the name of the service that you want to stop). In other words, all the cmdlets that are designed for actions related to system services will use the Service noun. Similarly, cmdlets that interact with system processes use the Process noun.
PowerShell Cmdlet Parameters
Most PowerShell cmdlets also accept various parameters. The required and accepted parameters of each cmdlet is a little bit different because the parameter must be based on the cmdlet’s purpose. Even so, you will find that while some parameters are unique to a particular cmdlet, others are used again and again.
I noted above that if you want to stop a service, you must supply the name of the service that you want to stop. The name is entered with the Name parameter. Generally speaking (and there are exceptions), anytime that you must supply a named value to a PowerShell cmdlet, you can usually use the Name parameter to do so. That holds true whether you tell PowerShell the name of a service, process, virtual machine, or just about anything else.
Learn powerShell 2
Figure 2. Many PowerShell cmdlets use the Name parameter.
Of course, this raises the question of how you can know which parameter goes with which cmdlet.
One option is to consult the documentation. If you do a web search about a particular PowerShell cmdlet, you will find that Microsoft has a dedicated webpage for it. The page lists all the cmdlet’s parameters and provides examples of how to use the cmdlet.
Learn powerShell 3
Figure 3. Microsoft provides documentation like this one for every PowerShell cmdlet.
PowerShell Integrated Scripting Environment (ISE) also provides help. As you type the name of a cmdlet, PowerShell ISE supplies you with a list of the parameters that you can use, as shown in Figure 4.
Learn powerShell 4
Figure 4. PowerShell ISE provides help as you type a cmdlet.
You can always type Get-Help, followed by the name of the cmdlet you need help with (notice that the Get-Help cmdlet uses the Get verb, shown in Figure 5).
Learn powerShell 5_0
Figure 5. Use Get-Help for help using any PowerShell cmdlet.
Keep It Safe
When you learn PowerShell, it involves more than just memorizing a few cmdlets and understanding what parameters to use. The only way to truly learn PowerShell is by experimenting with the various cmdlets. However, before doing so, I recommend setting up a dedicated physical or virtual machine to use solely for practicing PowerShell.
The reason you should use a practice environment is because PowerShell is both a programming language and a Windows management tool. As such, some of the cmdlets can be destructive if they are used improperly. Creating an isolated environment lets you experiment with PowerShell without jeopardizing your production environment.
Learn From PowerShell Users
Finally, perhaps the best thing you can do to learn PowerShell is to learn from others.
Suppose that you want to know how to perform a particular task, such as displaying system processes. You could Google terms such as “PowerShell cmdlet for listing processes” or “how do I list processes in PowerShell.” Google will usually serve up advice from other PowerShell users. Depending on the complexity of the task, you might not always totally understand the solution. However, you can always look up any of the individual cmdlets that are used in the solution.
You can also experiment with changing the values assigned to the various parameters used. By doing so, you will be able to get a better feel for how the cmdlets work.
Want more resources about how to learn PowerShell? Read these how-to articles below:
About the Author
You May Also Like