DEV Community

Cover image for Discover Commands with Get-Command in PowerShell
arnostorg
arnostorg

Posted on

Discover Commands with Get-Command in PowerShell

Discover Commands with Get-Command in PowerShell

Are you new to PowerShell and wondering where to even start finding commands? This guide shows you the fastest way to discover what you need using Get-Command.

What You'll Learn

  • Finding PowerShell commands by name pattern
  • Using wildcards to search effectively
  • Understanding verb-noun naming conventions
  • Filtering commands by type and module
  • Best practices for command discovery

Basic Command Discovery

The Get-Command cmdlet is your guide to what PowerShell can do. Let's start simple:

# List ALL available commands (useful for exploring)
Get-Command

# Search for commands containing a word (much more useful!)
Get-Command -Name '*process*'
Enter fullscreen mode Exit fullscreen mode

The -Name parameter lets you search. The * wildcard means "match anything" - so *process* finds all commands with "process" in the name.

Real Examples: Finding What You Need

Example 1: Working with Files

You need to copy files. What's the command?

# Search for file-related commands
Get-Command -Name '*item*'
Enter fullscreen mode Exit fullscreen mode

Output shows:

  • Get-Item - read file info
  • Copy-Item - duplicate files
  • Remove-Item - delete files
  • Move-Item - relocate files

Tip: "Item" is PowerShell's word for "file or folder"

Example 2: Working with Processes

You need to find running programs. What command exists?

# Search for process commands
Get-Command -Name '*process*'
Enter fullscreen mode Exit fullscreen mode

You'll see:

  • Get-Process - list running processes
  • Stop-Process - end a process
  • Wait-Process - pause until process ends

Example 3: Finding Text in Files

You need to search file contents. What exists?

# Search for content commands
Get-Command -Name '*content*'
Enter fullscreen mode Exit fullscreen mode

Results:

  • Get-Content - read file contents
  • Set-Content - write to files
  • Add-Content - append to files

Understanding Verb-Noun Naming

PowerShell uses a simple naming pattern: Verb-Noun

Common verbs:

  • Get- retrieve information
  • Set- change configuration
  • New- create something
  • Remove- delete something
  • Add- insert into collection
  • Copy- duplicate
  • Move- relocate
  • Stop- terminate
  • Start- begin
  • Clear- remove contents

Common nouns:

  • Item - a file or folder
  • Process - running program
  • Content - file contents
  • Service - Windows service
  • Variable - stored data
  • Object - generic thing

Once you know this pattern, finding commands becomes easy.

# Find all "Get" commands
Get-Command -Verb Get

# Find all commands working with "Process"
Get-Command -Noun Process

# Find all "Copy" operations
Get-Command -Verb Copy

# Result: You can mentally predict commands before typing them!
Enter fullscreen mode Exit fullscreen mode

Finding Commands by Their Verbs

Here's how professional operators think:

# List ALL verbs PowerShell recognizes
Get-Verb

# This is powerful! Once you see what verbs exist, 
# you can guess what commands exist.
Enter fullscreen mode Exit fullscreen mode

Handling Module Issues

Sometimes a command doesn't show up, but you know it should exist:

# Search including commands from modules not loaded yet
Get-Command -Name '*azure*' -ListAvailable

# Once you find it, load the module:
Import-Module Az.Storage

# Now that command appears in normal Get-Command searches
Enter fullscreen mode Exit fullscreen mode

Mistakes to Avoid

Wrong: Using aliases in your scripts

# This works in interactive sessions:
dir
ls
pwd

# But fails in scripts on other computers (aliases don't exist everywhere)
Enter fullscreen mode Exit fullscreen mode

Right: Use full command names in scripts

# Always use the real command name in scripts:
Get-ChildItem
Get-Location
Enter fullscreen mode Exit fullscreen mode

Wrong: Confusing similar command names

# These are different! Huge difference:
Get-Content    # READ file contents (safe)
Set-Content    # REPLACE file contents (destructive!)
Add-Content    # APPEND to file
Clear-Content  # EMPTY file without deleting it
Enter fullscreen mode Exit fullscreen mode

Connecting to Practical Learning

Learn it through Practice:

Don't just read about this - practice actually discovering commands:

👉 Practice Get-Command on your browser

The interactive practice environment walks you through real command discovery workflows.

Next Steps in Your Learning

This is part of the PowerShell for Beginners series:

  1. PowerShell Basics - Getting started
  2. ← You are here: Command Discovery - Find what exists
  3. Getting Help - Understand commands
  4. Working with Files - Copy, move, delete
  5. Filtering Data - Where-Object and Select-Object
  6. Pipelines - Chain commands together

Quick Reference Cheat Sheet

# Find commands containing a word
Get-Command -Name '*word*'

# Find all commands of a specific verb
Get-Command -Verb Get

# Find all commands working with a noun
Get-Command -Noun Process

# See if a module has more commands
Get-Command -ListAvailable

# See what verbs PowerShell recognizes
Get-Verb

# Get help for a command before running it
Get-Help Get-Process -Examples
Enter fullscreen mode Exit fullscreen mode

Related Resources

Summary

Get-Command is your compass in PowerShell. You don't need to memorize thousands of commands - just understand the verb-noun naming pattern, then use Get-Command to find what exists.

Start small: Look for commands using patterns like *item*, *process*, *content*. Notice the verbs and nouns. Soon you'll be able to predict command names before typing them.


Next: Learn how to get help for commands once you find them.

Have questions? Drop them in the comments - I read and respond to every one!

Top comments (0)