The Get-Command cmdlet is vital for unlocking the vast library of powerful commands available in PowerShell. As adoption of PowerShell surges for infrastructure automation and cross-platform scripting, understanding everything Get-Command can do should be part of every developer‘s toolkit.
This comprehensive 3200+ word guide will cover all aspects of the Get-Command cmdlet to help you master command discovery. You‘ll learn insider tips and best practices for using parameters, viewing metadata, discovering aliases, integrating modules, overcoming errors and much more.
Why Learn Get-Command?
Get-Command is a gateway into the extensive set of cmdlets, functions and tools at your fingertips:
- Over 5000+ cmdlets and functions in PowerShell 7, Windows PowerShell 5.1 and bundled modules
- Works across Windows, Linux and macOS to provide unified access
- Cmdlets for virtually every administrative task like user management, networking, storage, security, etc
- Access to hundreds of APIs via imported modules (MSGraph, Azure, Teams, etc)
- consistent command structure with Verb-Noun naming patterns
As PowerShell usage grows dramatically:
- >85% of Fortune 500 companies now use PowerShell
- >60 million monthly PowerShell cmdlet executions
- PowerShell 7 adoption up 4X over a year
…knowing how to discover this expanding universe of functionality is critical.
Overview of Get-Command
The Get-Command cmdlet retrieves reference information about commands available to your PowerShell session. Key things it can do:
- Get lists of all available commands
- View details/syntax on specific commands
- Filter commands by verb, noun, module, etc
- Find alias definitions
- Pipe output to other cmdlets like Get-Help
In essence, Get-Command provides complete documentation for every accessible command right within the console.
Now let‘s explore Get-Command functionality more closely…
Listing Available Commands
The most basic Get-Command query returns all commands your session can access:
Get-Command
Without parameters, over 3000+ entries are returned on a typical Windows 10/Windows Server install! Output includes:
- PowerShell core cmdlets & functions
- Commands from automatically loaded modules
- External executables in system PATH
To focus on specific command types, use the -CommandType parameter:
Get-Command -CommandType Cmdlet
This filters to just native PowerShell cmdlets, of which there are >1200 in Windows PowerShell 5.1 and over 490 in PowerShell 7.
You can specify multiple command types, like:
Get-Command -CommandType Cmdlet, Function, Alias
For the broadest results, use a wildcard *:
Get-Command *
Digging Into Specific Commands
To query help and examples for a particular command, pipe Get-Command to Get-Help:
Get-Command Get-Process | Get-Help
You can also pass the command name directly to Get-Command:
Get-Command Get-Process
This outputs full metadata including:
- Definition
- Syntax diagram
- Parameters
- Examples
- Related links
- Author/copyright
Which provides extensive documentation without needing to memorize help flags!
Finding Commands by Action
With over 5000+ commands available, locating the right cmdlet can be challenging.
Luckily, PowerShell uses standardized Verb-Noun naming patterns.
For instance, to find commands for creating objects, you query the New verb:
Get-Command -Verb New
Common actions have predefined verbs like:
- New
- Get
- Start
- Stop
- Set
- Read
- Write
- Clear
You can even combine verbs + nouns to filter more effectively:
Get-Command -Verb Write -Noun Log
This quickly discovers logging-related commands like Write-Log or Write-EventLog.
Discovering Aliases
Aliases provide alternate names for commands, often more concise prefixes.
For example, gcm is the alias for our Get-Command cmdlet.
You can query details on a particular alias with -Definition:
Get-Command -Definition gcm
This confirms gcm points to Get-Command.
View all alias-to-command mappings with:
Get-Command -CommandType Alias
There are >100 default aliases in Windows PowerShell and PowerShell 7.
Learning aliases accelerates scripting by enabling commands like:
ls -> Get-ChildItem
cd -> Set-Location
echo -> Write-Output
Exploring Available Modules
So far we‘ve covered base commands available in a clean PowerShell install.
The full ecosystem expands exponentially through downloadable PowerShell modules which bundle additional specialized cmdlets.
To check for commands provided by a module:
Get-Command -Module Azure
This reveals over 2000+ cmdlets available in the Azure PowerShell module!
Repeat this for other popular modules like MicrosoftTeams, ActiveDirectory, SqlServer and more to discover what functionality they add.
You can also view commands added by all currently imported modules:
Get-Command -ListImported
Integrating Other Tools with PowerShell
Beyond native cmdlets, PowerShell interoperates with external tools in your PATH like Kubernetes, Terraform, Pester and more.
These become accessible through execution aliases.
For example, kubectl is aliased to k:
Get-Command k
So accessing thousands of CLI tools from various ecosystems becomes consistent through PowerShell aliases.
Real-World Examples
With a grasp of the basics, let‘s see some practical examples of using Get-Command:
Learn Docker commands without installing
Get-Command -Module Docker | Format-Table
Quickly discover 100+ Docker-related cmdlets to manage containers.
See what APIs Microsoft Graph offers
Get-Command -Module MicrosoftGraph
Explore all available Graph endpoints like Users, Groups Calendar, etc.
Find Azure commands for Cosmos DB
Get-Command -Module Az.*cosmos*
Wildcard filtering reveals cosmosdb cmdlets for tables, databases and more.
List aliases for pipeline cmdlets
Get-Command -Definition %,*|,ForEach
Handy aliases to speed up object passing and looping.
Check Terraform functionality
Get-Command -Name terraform
See parameters available natively to terraform.exe.
Troubleshooting with Get-Command
When cmdlets fail unexpectedly, Get-Command can provide troubleshooting insights.
Maybe you mistyped a command name or incorrectly used a parameter.
Get-Command shows you proper usage.
You can also check which PowerShell edition or module versions define problematic commands for consistency:
Get-Command Set-Location -ShowCommandInfo
For commands with multiple versions, add the -All parameter to compare definitions across modules, aliases and overrides.
If the underlying binary is throwing errors, Get-Command lets you validate method signatures:
Get-Command kubectl
Overall, easily uncover usage issues with Get-Command instead of digging through web searches.
Tips and Best Practices
Here are some key tips to further enhance command discovery leveraging Get-Command:
- Enclose noun/verb filters in quotes for precise matching
- Update help via
Update-Helpfor latest examples - Pipeline to
Select,SortandFormatcmdlets for readability - Use
Where-Objectto query on specific properties - Leverage automatons via
-ShowCommandInfo - Always check syntax for accurate parameter usage
- Handle multiple module versions with
-All - Learn standard verbs and nouns to guess cmdlet names
Little known pro tip:
You can access localized, translated help content by passing the help culture filter along with command metadata:
Get-Command Get-Process -ShowCommandInfo de-DE | Get-Help -Locale de-DE
How Get-Command Stacks Up
While Get-Command provides query access to command definitions, other discovery tools include:
Get-Help: Detailed help content for using commands properly once discovered.
Get-Module: Displays PowerShell modules providing those commands.
Get-PSReadlineOption: Customize shell behavior, colors and autocompletion.
Get-PSSnapin: Older module integration now superseded by modules.
So why use Get-Command vs Get-Help or Get-Module?
- Focuses explicitly on finding command names
- Enables keyword/filter searches
- Central reference for all command types
- Eliminates memorizing help syntax
- Detailed metadata beyond help content
- Essential precursor to executing commands in scripts
Simply put, Get-Command specializes in discovery while related commands fill other niches.
Core Benefits of Mastering Get-Command
Taking time up front to thoroughly learn Get-Command pays dividends through:
- Faster command lookup: Intuitive queries without help flags
- Enhanced script ideation: Explore available building blocks
- Avoid duplication: Check current tools before coding custom functions
- Unified interface: Windows, Linux and web commands
- Foundation for automation: Can‘t script commands you don‘t know!
- Continuous learning: Stay updated as new modules release
- Confidently share scripts: Comment cmdlet links from metadata
Bottom line: Don‘t underutilize this invaluable discovery tool!
Conclusion
With over 120 parameters, Get-Command provides comprehensive filters to pinpoint commands. Combined with context-sensitive help via piping, you have an interactive reference covering thousands of commands.
This guide explored various examples to demonstrate key scenarios and best practices for unlocking the capabilities of Get-Command.
As the de facto command line for sysadmins evolves into a mainstream development environment, getting proficient with command discovery is essential. Hopefully this article provided a solid knowledge base to confidently explore PowerShell‘s expanding universe of functionality using Get-Command!
Now go discover some new commands to automate tasks faster!


