How do I continue improving my PowerShell skills?

Featured image

Why?

Learning PowerShell and all it’s features can seem daunting so it’s best to pick up the basics and start using that knowledge by trying things out. When you get stuck knowing how to use Get-Help and other useful commands will help you figure things out as you go.

Making a habit of using the help built right into PowerShell instead of running to a Google search saves precious time and effort.

TAB and the road to discovery

Even if you’re a complete beginner using PowerShell and the only thing you know about commands is that they begin with get-, you’ll still be able to learn more by simply pressing the TAB key on your keyboard.

On first press, get- will become Get- and on second press, you’ll be asked if you want to see over 1000 possibilities. Since that’s too many, press n.

TAB once in PowerShell

Instead we can filter the results by typing Get-c and this time pressing TAB twice shows us all the Powershell commands that begin with Get-C. You’ll see commands listed like Get-Culture and Get-Command.

TAB twice in PowerShell

By simply pressing the TAB key, PowerShell will remind you of half remembered commands, help you find new ones and auto-complete commands to save you typing, especially with long commands (type in enough of the command until there are no other matches and press TAB).

Access help about almost anything

We found a command called Get-Culture by using the TAB key but what does it do? We can find out by using the Get-Help command:

Get-Help Get-Culture

We get the help entry for this command:

Get-Help gives us the help entry for any command

The synopsis and description sections give us enough info to understand what the command does (it gives us locale and language settings).

The command results show that the culture settings on my computer are for the UK:

Get-Culture shows the computer’s locale and language settings

One of the most useful parameters (or switches) when using Get-Help is the -Examples switch which includes examples of how to use the command:

Get-Help Get-Culture -Examples

You’ll find that looking through the examples will show you how to solve the problem at hand in most cases.

Find commands you don’t know about yet

PowerShell generally uses the naming convention:

Verb-Noun

(descriptive action)-(identifying name)

Anytime you need to find a command to help with something you’re working on, you can take advantage of the verb-noun standard by using the Get-Command.

Get-Command -Verb Get

This lists all the commands that start with Get-, and if you want to find other verbs, you can use the Get-Verb command. You could even see all commands based on the available verbs:

Get-Command -Verb (Get-Verb).Verb

Using the wildcard * is more useful when you need targeted help like finding a command that has the word computer in the noun:

Get-Command -Noun *computer*

Using the Noun switch with wildcards

If you needed to restart your computer using PowerShell, the Restart-Computer command looks like a good candidate. How can we be sure? Use the Get-Help command of course!

You’ll find it can be used to restart your local computer but can also be used to restart a remote computer. You could also restart serveral remote computers and if you’re looking for automation, you could restart several computers remotely based on a list of computer names in a text file.

I think you get the idea. Using the Get-Command with the -Verb and -Noun switches along with the wildcard * can help you find a command for exactly what you need to do.

Documentation is only as good as the last update

The help documentation for PowerShell is regularly updated and it’s a good idea to stay up to date by using the Update-Help command every so often:

Keep help up-to-date with Update-Help

Note: I suggest using the -UICulture switch and setting it to En-US. I live in the UK and find that the update fails without this switch.

The other option to get the latest help files is to use the -Online switch which opens the latest help content in your default browser:

See PowerShell help in a browser using the -Online switch

Both these options assume you have an internet connection on the computer or server you’re working on.

Dig deeper

Sometimes you have some more time to investigate further or feel like you need to learn more about a specific topic. No problem!

Check out the about* pages which provide a wealth of information for the curious:

about* pages have a wealth of information

In this example, we’ve used the wildcard * again. If you’re not sure what it does exactly, you can find out in the about_Wildcards page:

about_Wildcards

Where to now?

Learning in small chunks regularly is an effective way of learning and retaining information. Using the PowerShell help documentation as and when needed is a way of focusing on the problem at hand and finding a solution that works at the time.

You may find that as your knowledge builds you find a better way of solving the same problem but remember without the initial methods learnt you’ll probably never get to the better ways of doing things in PowerShell.