The first you cmdlet you’re going to want to be aware of is the one that gives you an overview of what you can do! This is where get-help comes in handy. By typing get-help into PowerShell you’ll receive a comprehensive overview of what PowerShell is and you’ll be able to get a handle on the basic structure of its functionality. You can access documents on the web for more advanced help through this interface or even download help files than can then be explored within PowerShell itself. But the help command offers more.
This cmdlet will give you a list of all the cmdlets that you have access to at the moment. This is going to be a pretty big list in most circumstances, but it can be a lot of fun to explore all the possibilities.
This cmdlet will download all the latest help files from the internet so they're available right inside your PowerShell window.
Get-Help <command name>
Instead of “
With this cmdlet, you can get basic information about a specific command. It will provide a simple explanation of a cmdlet’s functionality so you can understand what it does.
Get-Help <command name> -Full
This command provides you with a more detailed explanation of what a specific cmdlet does.
Get-Help <command name> -Example
This help command goes even farther, providing you with an example of how the command might be used. In this way, you can fully explore the PowerShell environment without leaving PowerShell at all!
Get-Command allows you to retrieve information about specific commands or sets of commands in a quick and efficient manner. There are a ton of options with Get-Command that extend well beyond what a basic user would need, so we’re going to just focus on a couple of the basic ones, specifically those that will help you navigate the available commands.
This allows you to get a specific list of cmdlets based on their type. For the most part, a new user will probably just use the “cmdlet” type as we see in my next example.
Get-Command -Type Cmdlet | Sort-Object -Property Noun | Format-Table -GroupBy Noun
This more complicated phrase tells the computer that the user wants to get a list of all cmdlet type commands, that it wants to sort them alphabetically by the noun in their name, and then displays them in noun-based groups. This makes it easy to explore some of the possible commands. It is also a good example of how more complicated tasks can be accomplished using PowerShell — one a user is familiar with the syntax, using PowerShell is often the fastest method of getting things done.
Get-Command -Name <name> will pull up a command by its exact name.
This is one of my favorite commands because it allows you to search for things in the rough ballpark of a known name. This can be useful if you don’t know the name of a cmdlet you’re looking for, but might guess part of the name, or if you’re prone to misspellings. In either case, what this does is try to find commands that most closely match what you type.
This might look like the following:
Get-Command -Name <name> -UseFuzzyMatching
Alright, but what about some specific commands in PowerShell that allow you to interact with your system, that’s what we’re here for, right?
Using the Get-Item command, you have access to a powerful tool for searching your computer for a file that you need. This can be faster in many cases than trying to use the GUI (graphical user interface) search provided by Microsoft.
You use this command by specifying the location on your computer that you want to search. For instance, you could find your “C:” harddrive location by using the command like so:
Or you could go deeper into a directory and see everything contained in that directory, by using “*”.
Would return a list of all the directories contained under that user’s profile (and these would likely be further directories like “documents” and “downloads.”
As always, the best way to see how this works is to play around with it for a little while.
Using this command, you can get the content of a file on your computer. In most cases this will be a massive wall of confusing code, but in the above case it’s just the contents of a plain text file I placed on my desktop for this purpose. All you need to do is specify the location of the item in question.
On it’s own, this command is quite simple, but learning about it here sets you up for learning how to use it in conjunction with other commands where it can become quite powerful.
Using the “Service” command is one of the most powerful and useful, especially if you’re administering a network, but also if you’re just an ordinary user. What this does is allow you to see what services are running on your computer and control them.
This will grab a list of all the services running on your computer, from main programs like your browser, to all the other programs running in the background that make your computer run.
You can also use the following commands to control a service directly, say, if it’s frozen.
Restart-Service <service name>
Or you can stop it:
Stop-Service <service name>
Or start it up again:
Start-Service <service name>
Get-Process brings up information about the processes currently running on your system, such as their memory usage and their ID.
Likewise you can use the “Start” or “Stop” prefix instead of
Get, followed by the name or ID of a process to either stop or start a process.
Clear is a super useful command for when you've filled up your PowerShell console to the brim with help text and attempts at various commands. Rather than having to close the program and restart, just type "
clear " and you'll be brought back to a nice clean slate.
Cycling through previous entries is going to help you save a ton of time retyping or copy/pasting. In the PowerShell console you can bring up previous commands that you typed by simply pressing the "Up" arrow on your keyboard! This is invaluable when you're playing around with a cmdlet and need to try several different phrasings to get it to turn out right.
These commands are all simple on their own, but they will hopefully help provide you with a framework for some of the things that you can do with PowerShell, as well as for how PowerShell functions. Learning PowerShell can allow you to create powerful scripts that let you execute complex tasks on your computer, like the one I use in my Chocolatey guide.
Learning how to navigate your computer through PowerShell instead of purely through your GUI will afford you a greater degree of control over your device as well as provide a whole new playground for how you interact with your PC.
Windows is an incredibly versatile tool, an operating system with enough freedom to handle a huge range of tasks, from playing games to writing novels.