Aliases, External Commands, and Providers

Summary: in this tutorial, you will learn learn powershell aliases for productivity, run external programs, and explore providers for unified access to registry, environment, and more.

Aliases, External Commands, and Providers

Now that you know how to discover and use cmdlets, let's explore the features that make daily PowerShell use more productive: aliases for shorter commands, running external programs seamlessly, and PowerShell Providers that give you filesystem-like access to the registry, environment variables, certificates, and more.

Aliases: Shortcuts for Interactive Use

Typing full cmdlet names every time would be tedious for interactive use. That's why PowerShell includes aliases—short names that map to cmdlets.

What Are Aliases?

An alias is simply a nickname for a command. For example:

# These are all equivalent:
Get-ChildItem
dir         # Alias
ls          # Alias
gci         # Alias
 

All three aliases do exactly the same thing as Get-ChildItem.

Discovering Aliases

# See all aliases
Get-Alias
 
# Find what an alias points to
Get-Alias ls
# Output: CommandType: Alias, Definition: Get-ChildItem
 
# Find all aliases for a cmdlet
Get-Alias -Definition Get-ChildItem
# Output: dir, gci, ls
 

Common Built-in Aliases

PowerShell includes aliases that mimic common Windows (CMD) and Unix/Linux commands:

File System Aliases:

ls, dir, gci → Get-ChildItem      # List files
cd, chdir, sl → Set-Location      # Change directory
pwd, gl → Get-Location            # Print working directory
cat, gc, type → Get-Content       # Read file
cp, copy, cpi → Copy-Item         # Copy file
mv, move, mi → Move-Item          # Move/rename
rm, del, ri → Remove-Item         # Delete
mkdir, md → New-Item -Type Directory   # Make directory
 

Output Aliases:

echo, write → Write-Output        # Output data
cls, clear → Clear-Host           # Clear screen
 

Pipeline Aliases:

%ForEach-Object               # Iterate over pipeline
?Where-Object                 # Filter pipeline
select → Select-Object           # Choose properties
sort → Sort-Object               # Sort
measure → Measure-Object         # Count/sum/average
 

Formatting Aliases:

ft → Format-Table                # Display as table
fl → Format-List                 # Display as list
fw → Format-Wide                 # Display in columns
 

Web Aliases:

iwr → Invoke-WebRequest          # HTTP requests
irm → Invoke-RestMethod          # REST API calls
curl, wget → Invoke-WebRequest   # Unix-like names
 

Creating Your Own Aliases

You can create custom aliases for commands you use frequently:

# Create an alias
Set-Alias -Name np -Value notepad
Set-Alias -Name g -Value git
Set-Alias -Name py -Value python
 
# Now you can use them
np script.ps1        # Opens in Notepad
g status             # Runs git status
 

Removing Aliases

# Remove an alias
Remove-Alias -Name np
 

Aliases in Scripts: Don't Use Them

Critical: Never use aliases in scripts you share or in production code. Always use full cmdlet names.

Why? Because:

  1. Readability: Get-ChildItem is clear. gci requires you to know the alias.
  2. Portability: Custom aliases might not exist on other systems.
  3. Maintainability: Someone else reading your script might not know what % or ? mean.

Aliases are great for interactive use but terrible for scripts.

Running External Commands and Applications

PowerShell doesn't just run PowerShell cmdlets—it can also run any external program, executable, or script.

Running Executables Directly

You can run external commands just by typing their name:

# Run Windows commands
ping google.com
ipconfig /all
netstat -ano
 
# Run installed applications
notepad
code .              # VS Code
git status
npm install
python script.py
 

PowerShell looks for executables in your $env:PATH environment variable, just like other shells.

The Call Operator (&)

When the executable path contains spaces or special characters, or when the command is stored in a variable, use the call operator &:

# Path with spaces requires quotes and the call operator
& "C:\Program Files\Git\bin\git.exe" status
 
# Command stored in a variable
$cmd = "git"
& $cmd status
 
# Dynamic command building
$program = "C:\MyApp\app.exe"
$args = @("/silent", "/log:output.log")
& $program $args
 

The call operator tells PowerShell "execute this as a command."

Using Start-Process for More Control

For advanced scenarios, use Start-Process:

# Start an application
Start-Process notepad
 
# Start with arguments
Start-Process notepad -ArgumentList "C:\file.txt"
 
# Start and wait for it to finish
Start-Process notepad -Wait
 
# Open a file with its default application
Start-Process "document.pdf"
 
# Open a URL in the default browser
Start-Process "https://google.com"
 
# Run as administrator (UAC prompt)
Start-Process powershell -Verb RunAs
 
# Run hidden
Start-Process program.exe -WindowStyle Hidden
 

Capture Output from External Commands

External commands output text, not objects. To capture their output:

# Capture output in a variable
$output = git status
$output    # View captured output
 
# Parse line by line
git log --oneline | ForEach-Object {
    if ($_ -match "fix") {
        Write-Host "Bug fix: $_"
    }
}
 

PowerShell Providers: A Unified Interface

Here's where PowerShell gets really interesting. PowerShell uses the concept of providers to let you navigate different types of data stores using the same familiar cmdlets.

What Are Providers?

A provider is an adapter that makes a data store look like a file system. This means you can use the same navigation commands (Set-Location, Get-ChildItem, etc.) to work with:

  • The file system
  • The Windows Registry
  • Environment variables
  • PowerShell variables
  • Certificates
  • And more

Let's see what providers you have:

Get-PSProvider
 
# Output:
# Name         Capabilities                    Drives
# ----         ------------                    ------
# FileSystem   Filter, ShouldProcess           {C, D, ...}
# Registry     ShouldProcess                   {HKLM, HKCU}
# Environment  ShouldProcess                   {Env}
# Variable     ShouldProcess                   {Variable}
# Function     ShouldProcess                   {Function}
# Alias        ShouldProcess                   {Alias}
# Certificate  ShouldProcess                   {Cert}
 

Providers in Action

Here's the magic: the same cmdlets work with all providers. Let's see this in action.

Working with the File System (this is familiar):

# Navigate to a directory
Set-Location C:\Windows
 
# List contents
Get-ChildItem
 
# Create a new file
New-Item -Name "test.txt" -ItemType File
 
# Remove a file
Remove-Item test.txt
 

Now, the exact same commands work with the Registry:

# Navigate into the Registry
Set-Location HKCU:\Software
 
# List registry keys (just like files!)
Get-ChildItem
 
# Create a new registry key
New-Item -Name "MyApp" -ItemType Directory
 
# Remove a registry key
Remove-Item MyApp
 

Notice anything? The commands are identical. Set-Location, Get-ChildItem, New-Item, Remove-Item—they all work the same way. The provider adapts the data store to look like a file system.

Environment Variables:

# View all environment variables
Get-ChildItem Env:
 
# Get a specific environment variable
Get-Item Env:PATH
 
# Create a new environment variable
New-Item -Path Env:MY_VAR -Value "Hello"
 
# Access it
$env:MY_VAR
 

PowerShell Variables:

# See all variables
Get-ChildItem Variable:
 
# Get a specific variable
Get-Item Variable:PSVersionTable
 
# This is equivalent to:
$PSVersionTable
 

Functions:

# See all loaded functions
Get-ChildItem Function:
 
# View a function's definition
Get-Item Function:Prompt
 

Certificates (Windows):

# Browse certificate stores
Get-ChildItem Cert:\CurrentUser\My
 
# Find a specific certificate
Get-ChildItem Cert:\CurrentUser\My | Where-Object Subject -match "example"
 

Why This Matters: Understanding providers means you don't need to learn separate commands for the registry, environment variables, etc. You already know how to navigate and manipulate them—use the same file system commands!


Exercises

🏋️ Exercise 1: Command Discovery

Use Get-Command to find commands for these tasks. Try to find them without looking at the answers first:

  1. Find all commands that can "stop" something
  2. Find all commands related to network adapters
  3. Find a command to test if you can reach a network host
  4. Find commands that work with clipboard
  5. Find all commands from the module "Microsoft.PowerShell.Utility"
💡 Hint
Use Get-Command with -Verb, -Noun, or wildcards. Try Get-Command *keyword* for broad searches.
Show Solution
# 1. Commands that "stop" something
Get-Command -Verb Stop
# Shows: Stop-Process, Stop-Service, Stop-Computer, Stop-Job, etc.
 
# 2. Commands related to network adapters
Get-Command *NetAdapter*
# Or: Get-Command -Noun NetAdapter
# Shows: Get-NetAdapter, Enable-NetAdapter, Disable-NetAdapter, etc.
 
# 3. Test network connectivity
Get-Command *Connection*
Get-Command -Verb Test
# Answer: Test-Connection (like ping)
Get-Help Test-Connection -Examples
 
# 4. Clipboard commands
Get-Command *Clipboard*
# Shows: Get-Clipboard, Set-Clipboard
 
# 5. Commands from a specific module
Get-Command -Module Microsoft.PowerShell.Utility
# Shows all utility cmdlets like Select-Object, Where-Object, etc.
 
🏋️ Exercise 2: Help System Mastery

Use Get-Help to answer these questions. This exercise teaches you to read help documentation effectively:

  1. What are all the different parameter sets for Get-Process?
  2. Can Get-Process accept pipeline input? If so, what kind?
  3. What's the default value for the -First parameter in Select-Object?
  4. Read about_Comparison_Operators and explain the difference between -eq and -ceq
Show Solution
# 1. Parameter sets for Get-Process
Get-Help Get-Process
 
# SYNTAX section shows three parameter sets:
# Get-Process [[-Name] <String[]>] [-ComputerName <String[]>] ...
# Get-Process -Id <Int32[]> [-ComputerName <String[]>] ...
# Get-Process -InputObject <Process[]> [-ComputerName <String[]>] ...
 
# This means you can get processes by Name, by Id, or by InputObject
 
# 2. Pipeline input for Get-Process
Get-Help Get-Process -Full
 
# Look at the -Name parameter:
# "Accept pipeline input?  true (ByValue, ByPropertyName)"
# Yes, it accepts pipeline input by value and by property name
 
# 3. Default for -First in Select-Object
Get-Help Select-Object -Parameter First
 
# There is no default - it's optional. If omitted, all objects pass through.
 
# 4. -eq vs -ceq
Get-Help about_Comparison_Operators
 
# -eq is case-insensitive: "Hello" -eq "hello" → True
# -ceq is case-sensitive: "Hello" -ceq "hello" → False
 
🏋️ Exercise 3: Parameter Practice

This exercise builds your parameter skills:

  1. Use Get-ChildItem to find all .log files in C:\Windows\Logs (or /var/log on Linux/Mac), including subdirectories
  2. Use splatting to run the same command with parameters for Path, Filter, and Recurse
  3. Add error handling with -ErrorAction to silently ignore permission errors
  4. Use -WhatIf with Remove-Item to see what would be deleted (don't actually delete!)
💡 Hint
Remember: -Recurse is a switch, -ErrorAction SilentlyContinue ignores errors, and -WhatIf previews actions.
Show Solution
# 1. Find .log files recursively
Get-ChildItem -Path "C:\Windows\Logs" -Filter "*.log" -Recurse -ErrorAction SilentlyContinue
 
# On Linux/Mac:
Get-ChildItem -Path "/var/log" -Filter "*.log" -Recurse -ErrorAction SilentlyContinue
 
# 2. Using splatting (cleaner)
$params = @{
    Path        = "C:\Windows\Logs"
    Filter      = "*.log"
    Recurse     = $true
    ErrorAction = 'SilentlyContinue'
}
Get-ChildItem @params
 
# 3. Error handling is already included with -ErrorAction SilentlyContinue
# This prevents "Access Denied" errors from stopping the command
 
# 4. Safe deletion preview with -WhatIf
Get-ChildItem @params | Remove-Item -WhatIf
 
# Output will show:
# What if: Performing the operation "Remove File" on target "C:\...\file.log"
# But nothing is actually deleted!
 
# To actually delete (be careful!):
# Get-ChildItem @params | Remove-Item -Confirm
 

Summary

In this tutorial, you learned:

  1. Cmdlets are PowerShell's structured commands that work with objects, not text
  2. The Verb-Noun convention makes PowerShell self-documenting and discoverable
  3. Get-Command helps you find cmdlets by verb, noun, or wildcard patterns
  4. Get-Help provides comprehensive documentation right in the shell
  5. Parameters control cmdlet behavior - they can be named, positional, switches, or arrays
  6. Common parameters like -WhatIf, -Confirm, and -ErrorAction work with all cmdlets
  7. Splatting makes complex parameter sets cleaner and more maintainable
  8. Aliases provide shortcuts for interactive use but should never be used in scripts
  9. External commands can be run directly or with more control using Start-Process
  10. Providers let you use the same navigation cmdlets for files, registry, variables, and more

The commands you learned here—especially Get-Command and Get-Help—will be your constant companions as you continue learning PowerShell. Whenever you're unsure about a command, use these tools to teach yourself.

In the next tutorial, we'll explore the PowerShell Pipeline, which is how you chain commands together to create powerful one-liners.

Was this page helpful?
SR

Written by the ShellRAG Team

The ShellRAG editorial team writes practical, beginner-friendly PowerShell tutorials with tested code examples and real-world use cases. Every article is technically reviewed for accuracy and updated regularly.

Learn more about us →