PowerShell Genie

Get-Command tutorial: discover PowerShell commands

Get-Command answers the question you have most often, which is what is the command called. It searches everything available to your session: cmdlets, functions, aliases and external executables.

Lesson 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Overview

It filters the way you think about the problem. -Verb narrows by what you are doing, -Noun by what you are doing it to, and -Module by where the command comes from. Wildcards work in all of them, so Get-Command -Noun *Service* finds every command that deals with services regardless of verb.

The other use is inspection. Get-Command on a single name returns an object describing the command, including which module it came from and its full parameter list. That is how you find out whether the Get-ADUser on this machine is the real ActiveDirectory one or something a colleague wrote.

Get-Command searches only what is currently loadable. If a module is not installed, its commands will not appear, which is itself useful information.

What happens

-Noun Service asks for every command whose noun is Service, across all loaded modules. You get Get-Service, Set-Service, Start-Service, Stop-Service, Restart-Service and the others as a single list. This is how you learn a family of related commands at once rather than one at a time.

Worth remembering

  • Filter with -Verb, -Noun and -Module. Wildcards work.
  • Get-Command <name> tells you which module a command came from.
  • It finds aliases and external executables too.
  • Nothing appears for modules that are not installed.

Primary documentation

Get-Command reference

Try it

Browser simulation · fictional data; no changes to your computer.

Interactive simulation · fictional data

Lists every command whose noun is Service — the whole service-management family. Sample output from PowerShell 7; your versions and rows will differ. Wondering what a returned object can do?

Show reference output

Sample output · fictional data, shaped like the real thing

Name          Verb  Noun     Module                         
------------  ----  -------  -------------------------------
Get-Service   Get   Service  Microsoft.PowerShell.Management
Stop-Service  Stop  Service  Microsoft.PowerShell.Management

Practise this

Discover service commands

Find commands with the noun Service. Return the complete command records.

Review the lesson

Keep going

Next: Get-Help
Genie guideGet-Command tutorial: discover PowerShell commands

Get-Command answers the question you have most often, which is what is the command called. It searches everything available to your session: cmdlets, functions, aliases and external executables.