Cmdlets and Commands
Understand PowerShell cmdlets, the Verb-Noun naming convention, how to discover commands, and get help. Master the fundamental building blocks of PowerShell.
What are Cmdlets?
Cmdlets (pronounced "command-lets") are the fundamental building blocks of PowerShell. They are lightweight commands that perform specific actions and follow a consistent Verb-Noun naming pattern.
# Verb-Noun pattern examples
Get-Process # Get = Verb, Process = Noun
Set-Location # Set = Verb, Location = Noun
New-Item # New = Verb, Item = Noun
Remove-Item # Remove = Verb, Item = NounThis naming convention makes cmdlets predictable and discoverable. If you know the verb and noun, you can often guess the command name.
Common Verbs
PowerShell uses a standard set of approved verbs:
| Verb | Purpose | Example |
|---|---|---|
Get | Retrieve data | Get-Process, Get-Service |
Set | Modify data | Set-Location, Set-Content |
New | Create something | New-Item, New-Object |
Remove | Delete something | Remove-Item, Remove-Variable |
Start | Begin an action | Start-Process, Start-Service |
Stop | End an action | Stop-Process, Stop-Service |
Restart | Stop then start | Restart-Service, Restart-Computer |
Test | Verify/check | Test-Path, Test-Connection |
Invoke | Execute an action | Invoke-Command, Invoke-WebRequest |
Export | Save to a format | Export-Csv, Export-Clixml |
Import | Load from a format | Import-Csv, Import-Module |
ConvertTo | Convert format | ConvertTo-Json, ConvertTo-Html |
ConvertFrom | Convert from format | ConvertFrom-Json, ConvertFrom-Csv |
To see all approved verbs:
Get-VerbDiscovering Commands
Find All Available Commands
# List all commands
Get-Command
# Count total available commands
(Get-Command).Count
# List only cmdlets
Get-Command -CommandType Cmdlet
# List only functions
Get-Command -CommandType FunctionSearch for Specific Commands
# Find commands related to "process"
Get-Command *process*
# Find all "Get" commands
Get-Command -Verb Get
# Find all commands working with "Service"
Get-Command -Noun Service
# Find commands in a specific module
Get-Command -Module Microsoft.PowerShell.ManagementGetting Help
PowerShell has an excellent built-in help system. Always use it when you're unsure about a command.
Update Help Files
# Download the latest help files (run as Administrator)
Update-Help -ForceUsing Get-Help
# Basic help
Get-Help Get-Process
# Detailed help with examples
Get-Help Get-Process -Detailed
# Show only examples
Get-Help Get-Process -Examples
# Full technical documentation
Get-Help Get-Process -Full
# Open help in a browser window
Get-Help Get-Process -OnlineUnderstanding Help Output
# Get-Help shows:
# NAME - Command name
# SYNOPSIS - Brief description
# SYNTAX - How to use it (parameters)
# DESCRIPTION - Detailed explanation
# PARAMETERS - Each parameter explained
# EXAMPLES - Usage examplesParameters
Cmdlets accept parameters to modify their behavior. Parameters use a dash prefix:
# Named parameters
Get-Process -Name "notepad"
# Multiple parameters
Get-ChildItem -Path "C:\Users" -Recurse -Filter "*.txt"
# Positional parameters (order matters)
Get-Process notepad # -Name is positional, so you can skip it
# Switch parameters (no value needed)
Get-ChildItem -Recurse # -Recurse is a switch (on/off)Common Parameters
Every cmdlet supports these common parameters:
# -Verbose: Show detailed operation info
Get-Process -Verbose
# -WhatIf: Preview what would happen (doesn't execute)
Remove-Item "test.txt" -WhatIf
# -Confirm: Ask before executing
Remove-Item "test.txt" -Confirm
# -ErrorAction: Control error behavior
Get-Process -Name "nonexistent" -ErrorAction SilentlyContinue
# -OutVariable: Store output in a variable
Get-Process -OutVariable allProcessesAliases
Aliases are shortcuts for cmdlets. PowerShell includes many built-in aliases:
# Common aliases
ls # Get-ChildItem
dir # Get-ChildItem
cd # Set-Location
pwd # Get-Location
cat # Get-Content
echo # Write-Output
cls # Clear-Host
cp # Copy-Item
mv # Move-Item
rm # Remove-Item
mkdir # New-Item -ItemType Directory
# See all aliases
Get-Alias
# Find the alias for a cmdlet
Get-Alias -Definition Get-ChildItem
# Find what an alias maps to
Get-Alias ls
# Create your own alias
Set-Alias -Name np -Value notepad
Set-Alias -Name g -Value gitBest Practice: Use full cmdlet names in scripts for readability. Use aliases only in the interactive console for speed.
Running External Commands
You can run traditional commands and executables from PowerShell:
# Run native commands
ipconfig /all
ping google.com
nslookup example.com
# Run executables
notepad.exe
code .
# Run with arguments
git status
git log --oneline -10
# Use the call operator (&) for paths with spaces
& "C:\Program Files\MyApp\app.exe"Command History
# View command history
Get-History
# Search history
Get-History | Where-Object { $_.CommandLine -like "*process*" }
# Re-run a command by ID
Invoke-History 5
# Clear history
Clear-HistoryPractical Examples
Example 1: Explore Your System
# What version of PowerShell am I running?
$PSVersionTable.PSVersion
# What OS am I on?
$PSVersionTable.OS
# How many commands are available?
(Get-Command).Count
# What modules are loaded?
Get-ModuleExample 2: Find the Right Command
# I want to work with files...
Get-Command -Noun Item
# I want to get information about something...
Get-Command -Verb Get -Noun *computer*
# What can I do with services?
Get-Command *service*Example 3: Understand a Command
# What does Get-Service do?
Get-Help Get-Service -Examples
# What parameters does it accept?
(Get-Command Get-Service).Parameters.KeysExercises
Try these on your own:
- Find all cmdlets that contain the word "content"
- Use
Get-Helpto learn aboutTest-Connection - Create an alias called
procsthat maps toGet-Process - Find out what the alias
gcimaps to - Count how many "Get" commands are available on your system
In the next tutorial, we'll explore the PowerShell Pipeline — the most powerful feature of PowerShell!