0
0
PowershellHow-ToBeginner · 3 min read

How to Use Get-Command in PowerShell: Syntax and Examples

Use Get-Command in PowerShell to find commands, cmdlets, functions, or scripts available in your session. You can specify a command name or use wildcards to search broadly. For example, Get-Command Get-Process shows details about the Get-Process cmdlet.
📐

Syntax

The basic syntax of Get-Command lets you search for commands by name or type.

  • Get-Command [-Name] <string>: Finds commands matching the name or pattern.
  • Get-Command [-CommandType] <CommandTypes>: Filters commands by type like Cmdlet, Function, Alias, etc.
  • Get-Command [-Module] <string>: Shows commands from a specific module.

You can combine parameters to narrow your search.

powershell
Get-Command [-Name] <string> [-CommandType <CommandTypes>] [-Module <string>]
💻

Example

This example shows how to find the Get-Process cmdlet and list all commands starting with 'Get-'.

powershell
Get-Command Get-Process

Get-Command Get-*
Output
CommandType Name Version Source ----------- ---- ------- ------ Cmdlet Get-Process 7.0.0.0 Microsoft.PowerShell.Management CommandType Name Version Source ----------- ---- ------- ------ Cmdlet Get-Acl 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Get-ChildItem 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-Content 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-Process 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-Service 7.0.0.0 Microsoft.PowerShell.Management ... (more commands starting with Get-)
⚠️

Common Pitfalls

One common mistake is using Get-Command without quotes around wildcards, which can cause errors or unexpected results. Also, confusing Get-Command with Get-Help is frequent; Get-Command finds commands, while Get-Help shows usage info.

powershell
# Wrong: missing quotes around wildcard
Get-Command Get-*

# Right: use quotes to avoid parsing issues
Get-Command "Get-*"
📊

Quick Reference

ParameterDescriptionExample
-NameSearch commands by name or patternGet-Command -Name Get-Process
-CommandTypeFilter by command type (Cmdlet, Function, Alias)Get-Command -CommandType Cmdlet
-ModuleShow commands from a specific moduleGet-Command -Module Microsoft.PowerShell.Management
-SyntaxShow command syntax onlyGet-Command Get-Process -Syntax
-AllShow all commands including duplicatesGet-Command -Name Get-Process -All

Key Takeaways

Use Get-Command to find commands by name, type, or module in PowerShell.
Always quote wildcards like "Get-*" to avoid parsing errors.
Get-Command shows command details; use Get-Help for usage instructions.
Combine parameters to narrow down your command search effectively.
Use -Syntax to quickly see how to use a command.