Catalog / PowerShell Cheatsheet
PowerShell Cheatsheet
A concise reference for PowerShell commands, syntax, and best practices, designed to help both beginners and experienced users quickly find the information they need.
Core Cmdlets & Syntax
Basic Cmdlets
|
Retrieves all available cmdlets, functions, and aliases. Example: |
|
Displays help information about cmdlets, functions, and scripts. Example: |
|
Inspects the properties and methods of an object. Example: |
|
Creates and sets the value of a variable. Example: |
|
Displays output in the console. Example: |
|
Sends output as objects to the pipeline. Example: |
Basic Syntax
$ - Variable declaration ( |
Operators: |
Redirection: |
Data Manipulation & Scripting
Working with Data
|
Converts a JSON string to a PowerShell object. Example: |
|
Converts a PowerShell object to a JSON string. Example: |
|
Imports data from a CSV file. Example: |
|
Exports data to a CSV file. Example: |
|
Iterates through a collection of objects. Example: |
Conditional Statements
If/Else:
|
Looping
For Loop:
|
While Loop:
|
Do-While Loop:
|
Functions and Modules
Functions
Defining a Function: |
|
Calling a Function: |
|
|
Used to exit a function and optionally return a value. If no value is provided, nothing is returned. Example:
|
Modules
|
Imports a module into the current session. Example: |
|
Lists the modules that are imported in the current session. Example: |
|
Specifies which module members (cmdlets, functions, variables, aliases) are exported from a script module. Example: |
Error Handling & Advanced Features
Error Handling
Try/Catch/Finally:
|
|
|
Sets the default behavior when an error occurs. Common values: ‘Stop’, ‘Continue’, ‘SilentlyContinue’, ‘Inquire’. Example: |
|
Throws a custom exception. Example: |
Background Jobs
|
Starts a background job. Example: |
|
Retrieves background jobs. Example: |
|
Receives the output of a background job. Example: |
|
Stops a running background job. Example: |
|
Waits for a background job to complete. Example: |
|
Removes a background job. Example: |
Remoting
|
Starts an interactive session with a remote computer. Example: |
|
Runs commands on a remote computer. Example: |