PowerShell Basics and Cmdlets

The Verb-Noun Revelation

After installing PowerShell, I stared at the blank terminal, wondering how to find the right command. Coming from Linux, I was used to memorizing cryptic commands like ls, grep, awk. PowerShell felt different - more... organized.

I needed to find running services on a Windows server. In my mind, the command could be anything: services, list-services, show-services, or some abbreviation I'd never guess. Then I discovered PowerShell's naming convention:

Get-Service

It clicked immediately. "Get" the "Service". Want to stop a service? Stop-Service. Start a process? Start-Process. The pattern was everywhere. Within 30 minutes, I could guess command names with surprising accuracy.

This predictable naming convention changed everything. I wasn't memorizing random commands anymore - I was learning a system.

Understanding Cmdlets

Cmdlet (pronounced "command-let") is the term for PowerShell commands. Unlike shell functions or executables, cmdlets are specialized .NET classes designed for automation tasks.

The Verb-Noun Convention

Every cmdlet follows the pattern: Verb-Noun

Common Verbs:

  • Get - Retrieve data

  • Set - Change data

  • New - Create new items

  • Remove - Delete items

  • Start - Begin operations

  • Stop - End operations

  • Restart - Stop and start

  • Test - Verify conditions

  • Invoke - Execute or run

Examples:

Approved Verbs

PowerShell has a list of approved verbs to maintain consistency:

This returns all approved verbs with descriptions. When writing your own functions, using approved verbs makes them discoverable and consistent with the PowerShell ecosystem.

Discovering Commands with Get-Command

The most important cmdlet for learning PowerShell is Get-Command - it helps you find other commands.

Finding All Available Commands

On my system with several modules installed, I have over 2,000 commands available. Don't panic - you'll only use a fraction of them regularly.

Searching by Pattern

Filtering by Verb or Noun

Filtering by Type

Real-World Discovery Example

When I needed to manage Azure resources, I didn't know the specific commands. Here's how I discovered them:

This discovery pattern works for any module or technology.

Mastering Get-Help

Get-Help is your built-in documentation system. I use it multiple times daily, even after years of PowerShell experience.

Basic Help Usage

Updating Help Content

Help files aren't installed by default (to keep PowerShell lightweight). Update them:

Searching Help Content

Reading "About" Topics

PowerShell includes conceptual help topics:

These are goldmines of information. When I was learning error handling, Get-Help about_Try_Catch_Finally taught me everything I needed.

Understanding Cmdlet Syntax

Parameters

Parameters modify how cmdlets work. They follow the cmdlet name with a -ParameterName format:

Parameter Types

Positional Parameters:

Named Parameters:

Switch Parameters:

Finding Parameter Information

Tab Completion

PowerShell's tab completion is incredibly helpful:

Press Tab multiple times to cycle through options.

Common Cmdlet Patterns

Working with Services

Working with Processes

Working with Files and Folders

Aliases: Shortcuts for Common Commands

PowerShell includes aliases for frequently-used commands:

Viewing and Creating Aliases

Aliases in Scripts: A Warning

Don't use aliases in scripts. Use full cmdlet names for clarity:

Aliases are great for interactive use but reduce script readability.

The -WhatIf and -Confirm Parameters

Safety features that prevent accidental damage:

-WhatIf: Preview Without Executing

I use -WhatIf constantly when testing scripts that modify systems.

-Confirm: Prompt Before Executing

Real-World Application: Server Health Check

Here's a practical example using cmdlets we've learned:

This script checks services, disk space, and CPU usage - a simple health check I run on servers.

Common Pitfalls

1. Not Using Tab Completion

Problem: Typing full cmdlet names and parameter names manually Solution: Press Tab to autocomplete - saves time and prevents typos

2. Ignoring Get-Help Examples

Problem: Struggling to understand cmdlet syntax Solution: Get-Help <cmdlet> -Examples shows practical usage patterns

3. Using Aliases in Scripts

Problem: Scripts like ls | ? {$_.Length -gt 1MB} are hard to read Solution: Use full cmdlet names in scripts for clarity

4. Not Using -WhatIf for Destructive Operations

Problem: Accidentally deleting files or stopping critical services Solution: Always test with -WhatIf first:

5. Forgetting About Update-Help

Problem: Getting minimal help output Solution: Run Update-Help to download complete documentation

Key Takeaways

  • Verb-Noun naming makes commands predictable and discoverable

  • Get-Command helps you find commands by pattern, verb, or noun

  • Get-Help provides comprehensive documentation with examples

  • Parameters modify cmdlet behavior - learn to use them effectively

  • Tab completion saves time and prevents errors

  • -WhatIf lets you preview changes safely

  • Aliases are great interactively but avoid them in scripts

  • Approved verbs maintain consistency across PowerShell

What You've Learned

✅ The Verb-Noun naming convention ✅ How to discover commands with Get-Command ✅ How to master Get-Help for self-sufficiency ✅ Understanding cmdlet parameters and syntax ✅ Common cmdlet patterns for services, processes, and files ✅ Using aliases (and when not to) ✅ Safety features like -WhatIf and -Confirm

Next Steps

Now that you can find and understand cmdlets, it's time to learn PowerShell's most powerful feature: the pipeline. In The PowerShell Pipeline, you'll discover:

  • How the PowerShell pipeline differs from Unix/Linux pipes

  • Working with objects instead of text

  • Chaining cmdlets to build powerful one-liners

  • Common pipeline patterns you'll use daily

The pipeline is what makes PowerShell truly powerful - it's where everything comes together.


Ready to master the pipeline? Continue to The PowerShell Pipeline

Last updated