PowerShell Cheat Sheet: Essential Commands & Tips

A PowerShell cheat sheet is one of the most valuable resources for system administrators, developers, and IT professionals who work with automation and scripting in Windows or cross-platform environments. Whether you are a beginner trying to understand basic commands or an advanced user managing enterprise environments, having a reference guide saves time and reduces errors.

This detailed cheat sheet covers everything you need to get started with PowerShell commands, from syntax basics to system administration, file handling, networking, and scripting essentials.

What is PowerShell?

PowerShell is a task automation and configuration management framework developed by Microsoft. It combines a command-line shell with a powerful scripting language built on .NET.

Unlike traditional shells, PowerShell works with objects instead of plain text. This makes it extremely efficient for automation, configuration, and system management.

It is available on Windows, macOS, and Linux, making it a versatile tool for administrators and developers alike.

PowerShell Cheat Sheet Basics

When learning PowerShell, it’s important to understand the foundational concepts and syntax. Here are some key basics:

  • Cmdlets – PowerShell commands that follow a Verb-Noun format, like Get-Process.
  • Pipelines – Allow passing objects from one cmdlet to another using |.
  • Variables – Store values using $ (e.g., $name = "John").
  • Objects – Unlike traditional shells, PowerShell outputs rich objects.
  • Aliases – Shortcuts for cmdlets, e.g., ls for Get-ChildItem.

With these basics, you can start building scripts and managing systems efficiently.

Common PowerShell Cmdlets

Here’s a quick PowerShell cheat sheet of frequently used cmdlets:

  • Get-Help – Displays help about cmdlets.
  • Get-Command – Lists available commands.
  • Get-Service – Displays services running on the system.
  • Start-Service / Stop-Service – Manages services.
  • Get-Process – Shows running processes.
  • Stop-Process – Terminates a process.
  • Set-ExecutionPolicy – Configures script execution permissions.

Each of these commands can be combined with parameters for more advanced functionality.

PowerShell File and Directory Management

PowerShell is often used for managing files and directories. Here are key commands:

  • Get-ChildItem (ls, dir) – Lists files and directories.
  • New-Item -ItemType File -Name test.txt – Creates a new file.
  • Remove-Item filename.txt – Deletes a file.
  • Copy-Item source.txt destination.txt – Copies a file.
  • Move-Item source.txt destination.txt – Moves or renames a file.
  • Set-Location (cd) – Changes the working directory.

These commands streamline file management tasks, making automation scripts much more efficient.

PowerShell User and System Management

System administrators rely on PowerShell for user and system management.

  • Get-LocalUser – Displays local users.
  • New-LocalUser -Name "User1" -Password (Read-Host -AsSecureString) – Creates a new user.
  • Remove-LocalUser -Name "User1" – Deletes a user.
  • Get-Date – Shows the current date and time.
  • Restart-Computer – Restarts the system.
  • Get-HotFix – Lists installed updates.

These commands are especially useful when managing multiple systems via automation.

PowerShell Networking Commands

Networking is another area where PowerShell shines. Here are useful networking cmdlets:

  • Test-Connection google.com – Similar to the ping command.
  • Get-NetIPAddress – Displays IP configuration.
  • Get-NetAdapter – Lists network adapters.
  • Get-NetTCPConnection – Shows active TCP connections.
  • Resolve-DnsName example.com – DNS lookup.
  • New-NetIPAddress – Configures a new IP address.

These commands help administrators troubleshoot and configure networks directly from PowerShell.

PowerShell Scripting Essentials

Beyond single commands, PowerShell scripting allows for automation of repetitive tasks.

  • Variables:
$name = "TechAlmirah"
  • Loops:
For ($i=1; $i -le 5; $i++) { Write-Output $i }
  • Conditional Statements:
If ($a -gt $b) { Write-Output "A is greater" }
  • Functions:
Function Greet($name) { Write-Output "Hello, $name" }

Scripts are saved with .ps1 extension and can be executed with the right execution policy settings.

PowerShell Security and Execution Policy

By default, PowerShell restricts script execution to prevent malicious activity. The execution policy determines how scripts run:

  • Restricted – No scripts allowed.
  • AllSigned – Only signed scripts allowed.
  • RemoteSigned – Local scripts run; downloaded scripts must be signed.
  • Unrestricted – All scripts can run.

Use the following command to modify execution policy:

Set-ExecutionPolicy RemoteSigned

Always ensure security best practices when modifying execution policies.

PowerShell Cheat Sheet for Advanced Tasks

Advanced PowerShell users leverage more complex cmdlets and modules.

  • Importing Modules:
Import-Module ActiveDirectory
  • Working with JSON:
Get-Content data.json | ConvertFrom-Json
  • Exporting Data:
Get-Process | Export-Csv processes.csv
  • Task Scheduling:
Register-ScheduledTask
  • Managing Azure Resources:
Get-AzResource

These advanced features make PowerShell indispensable in DevOps, system administration, and cloud management.

Tips for Using PowerShell Effectively

  1. Use Get-Help <cmdlet> with -Examples to learn quickly.
  2. Create aliases for frequently used commands.
  3. Combine cmdlets with pipelines for powerful one-liners.
  4. Regularly update PowerShell modules for security and functionality.
  5. Practice scripting small tasks before moving to automation projects.

FAQ: PowerShell Cheat Sheet

1. What is a PowerShell cheat sheet?

A PowerShell cheat sheet is a quick reference guide containing essential commands, syntax, and examples that help beginners and professionals use PowerShell efficiently.

2. Can PowerShell run on Linux and macOS?

Yes, PowerShell Core is cross-platform and works on Windows, Linux, and macOS, making it a universal automation tool.

3. How do I run a PowerShell script?

Save your script with a .ps1 extension, then run it using .\script.ps1. Ensure your execution policy allows script execution.

4. What’s the difference between PowerShell and CMD?

CMD is a basic command-line interpreter, while PowerShell is object-oriented, supports advanced scripting, and integrates with .NET for automation.

5. Is PowerShell safe to use?

Yes, PowerShell is safe if used responsibly. Execution policies and signed scripts help maintain security while running scripts.

Scroll to Top