PowerShell Commands with Examples

In this guide, you will find all the PowerShell commands, along with relevant examples. I have explained each command in detail with examples.

Command NameCommand Description
PowerShell Start-ProcessStart-Process launches a new process or application with optional arguments, credentials, and window settings in PowerShell.
PowerShell Get-ProcessPowerShell Get-Process cmdlet retrieves detailed information about running processes on the local or remote computer, allowing filtering by name or ID.
PowerShell Read-HostRead-Host prompts the user for input during script execution, optionally masking sensitive data like passwords, and returns the entered string in PowerShell.
PowerShell Write-HostWrite-Host PowerShell cmdlet displays colored or formatted text directly to the console host for user interaction, without sending output to the pipeline.
PowerShell Write-OutputWrite-Output sends objects to the pipeline or displays them on the console, serving as the default output mechanism in PowerShell.
PowerShell Remove-ItemThe PowerShell Remove-Item cmdlet deletes files, folders, registry keys, and other items from various data stores. It supports recursive deletion, filtering, and can remove multiple items in a single command.
PowerShell new-itemNew-Item creates new files, folders, registry keys, or other items at a specified location, optionally setting initial content or values in PowerShell
PowerShell Copy-ItemPowerShell Copy-Item cmdlet copies files, folders, or other items from one location to another within the same namespace, supporting recursion and filtering.
PowerShell Get-ChildItemGet-ChildItem lists the items and child items in specified locations like directories or registry keys, supporting recursion and filtering in PowerShell.
PowerShell Select-StringSelect-String PowerShell cmdlet searches for text patterns in files or strings using regular expressions, returning matching lines with context like file name and line number in PowerShell.
PowerShell Sort-ObjectPowerShell Sort-Object cmdlet sorts objects in ascending or descending order based on specified property values, supporting multiple properties.
PowerShell Select-ObjectSelect-Object extracts specified properties or a subset of objects from a collection, enabling custom object creation and filtering in PowerShell.
PowerShell ForEach-ObjectPowerShell’s ForEach-Object cmdlet allows you to perform operations on each item in a collection as it passes through the pipeline.
PowerShell Compare-ObjectCompare-Object cmdlet in PowerShell compares two sets of objects and shows differences by identifying which objects exist in one set but not the other, supporting property-based comparisons.
PowerShell Where-ObjectWhere-Object filters objects in a pipeline based on specified conditions, allowing selection of items that match property values or custom criteria in PowerShell.
PowerShell Export-CSV cmdletExport-Csv converts objects into a CSV file by exporting their property values as rows, making it easy to share data and create spreadsheets in PowerShell.
PowerShell Import-Csv CmdletImport-Csv reads a CSV file and converts each row into a PowerShell custom object with properties based on the column headers, enabling easy data manipulation.
PowerShell Set-ContentSet-Content writes or replaces content in a file, supporting various encodings and the option to avoid adding a trailing newline in PowerShell.
PowerShell Test-PathTest-Path in PowerShell checks if a specified file, folder, or other path exists and returns a Boolean indicating its presence.
PowerShell Format-TableFormat-Table cmdlet in PowerShell formats command output as a customizable table, allowing selection of specific properties and adjusting column widths for better readability.
PowerShell Get-DateGet-Date retrieves the current date and time or a specified date, with options to format the output in various ways in PowerShell.
PowerShell New-VariableNew-Variable creates a new variable with an optional initial value and scope, allowing control over visibility and attributes in PowerShell.
PowerShell Out-FileThe PowerShell Out-File cmdlet sends command output directly to a text file, preserving its console formatting. It is commonly used for logging and saving reports.
PowerShell Invoke-WebRequestInvoke-WebRequest in PowerShell is used to send HTTP and HTTPS requests to web services or download files from the internet. It retrieves web content, headers, status codes, and more—ideal for APIs, web scraping, or automation.
PowerShell Test-NetConnectionTest-NetConnection in PowerShell is used to diagnose network connectivity, DNS resolution, and port availability. It’s a powerful built-in cmdlet for testing connections to remote hosts or URLs, including specific ports.
Add-Content in PowerShellThe Add-Content cmdlet in PowerShell is used to append text or data to the end of a file without overwriting its existing contents. It is commonly used for logging, updating records, or accumulating information in scripts.
Measure-Object in PowerShellMeasure-Object in PowerShell is a cmdlet used to calculate numerical properties like count, sum, average, minimum, and maximum of objects. It’s commonly used with pipelines to quickly analyze data, such as file sizes or string lengths.
100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.