PowerShell is a command-line interface for Windows 10 and 11. It provides a powerful scripting environment for automating system administration tasks. Built on the .NET Framework, it enables you to access and manipulate objects in Windows more easily and concisely than traditional shells, such as the Command Prompt. PowerShell commands, which are also called ‘cmdlets’, let you interact with your operating system like a pro and simplify complex tasks. Below is a list of all the essential commands for this powerful tool that will help you accomplish basic and advanced tasks.
The PowerShell interface consists of a console window and an integrated scripting environment (ISE).With its intuitive syntax and robust functionality, PowerShell enables users to perform a myriad of operations such as managing files and folders, manipulating registry entries, configuring network settings, executing remote management actions, or even accessing Active Directory resources. From basic administrative tasks like creating new user accounts or restarting services to more advanced functions like auditing security permissions or querying database information through SQL Server cmdlets – the possibilities are virtually limitless with PowerShell.
In this guide, we’ll introduce you to the basics of working with Windows PowerShell. We’ll start with an overview of the PowerShell console and its default settings. Then we’ll dive into working with cmdlets (command-lets) or commands which are the basic building blocks of any PowerShell script. There are commands for almost any system-level task. For example, you can use $PSVersionTable
to check the PowerShell version installed on your computer.
In most cases, people use the terms ‘command’ and ‘cmdlet’ synonymously. Both work like instructions for PowerShell telling it to perform specific tasks. However, there are a few differences between commands and cmdlets that you should keep in mind.
Below are some basic PowerShell terms and shortcut keys you should know, especially if you are a beginner. It is easy to launch this command-line tool but there are 17 ways to open PowerShell in Windows 10 and 11.
PowerShell commands and cmdlets form an extensive repertoire of tools that empower automation, streamline administrative tasks, and manipulate computer systems with precision. The following useful PowerShell commands are essential for any beginner or system admin seeking to optimize their efficiency in managing Windows environments.
Command name/Cmdlet | Alias | Description |
---|---|---|
Add-Content | ac | Adds content to the specified files. For instance, you can add words to a file. |
Add-PSSnapIn | asnp | Adds PowerShell snap-ins to the current session. |
Clear-Content | clc | Deletes the contents of a file while retaining the file. |
Clear-History | clhy | Deletes specific entries from the command history. |
Clear-Host | cls, clear | Removes all text (commands and output) from the current display. |
Clear-ItemProperty | clp | Clears the value of a property. |
Clear-Variable | clv | Clears the value of a variable. |
Compare-Object | compare, dif | Compares two sets of objects directly by generating reports on the differences between the objects. |
Connect-PSSession | cnsn | Reconnects to the disconnected sessions. |
Copy-Item | copy, cp, cpi | Copiesfiles and folders from a source file path to the destination file path. |
Copy-ItemProperty | cpp | Copies the value of a property from a specified location to another location. |
Disable-PSBreakpoint | dbp | Disables the breakpoints in the current PowerShell console. |
Disconnect-PSSession | dnsn | Disconnects from a PowerShell session. |
Enable-PSBreakpoint | ebp | Enables the breakpoints in the current PowerShell console. |
Enter-PSSession | etsn | Starts a PowerShell session with a remote computer. |
Exit-PSSession | exsn | Ends a PowerShell session with a remote computer. |
Export-Alias | epal | Exports information about currently defined aliases to a file. |
Export-Csv | epcsv | Converts objects into a series of character-separated values and saves the strings in a CSV file. |
Export-PSSession | epsn | Exports cmdlets and functions from another session on a computer and saves them in a PowerShell module. |
ForEach-Object | %, foreach | Performs modification or formatting on every item in a specified group of input objects (or items). |
Format-Custom | fc | Uses a customized view todisplay objects while retaining their basic structure. |
Format-List | fl | Formats the output of a command as a list of properties, showing each property on a new line. |
Format-Table | ft | Formats the output into table form. |
Get-Alias | gal | Gets the alias names for the cmdlets, functions, and scripts for the current session in PowerShell. If you want to find out or check the alias for a specific cmdlet, you can use Get-Alias -Definition cmdlet-name or gal -d cmdlet-name . |
Get-ChildItem | gci, dir, ls | Gets the files and folders from one or more specified locations, such as a file system directory, registry hive, or certificate store. |
Get-Command | gcm | Displays the list of all PowerShell commands and functions. |
Get-Content | gc, type | Gets the contents from a file without opening it and returns each text file line as a string object. |
Get-Date | Gets the current date and time. | |
Get-Help | Helps you to get to know all the PowerShellcommands, their parameters, functions, scripts, workflows, etc. | |
Get-History | h, ghy, history | Displays the list of the previous commands used in the current session. |
Get-HotFix | Gets hotfixes or updates that have been installed on either the local computer or remote computer. | |
Get-Item | gi | Gets files and folders at the specified location but doesn’t get the contents of the item unless you use a wildcard (*). |
Get-ItemProperty | gp | Getsthe registry entries or values in the readable format in the console. |
Get-Job | gjb | Gets the list of jobs running in the background, and those that have completed in the current session. |
Get-Location | gl, pwd | Gets an object that represents the current directory within PowerShell. |
Get-Member | gm | Displays the properties, methods, and different members of an object. |
Get-Module | gmo | Displays the list of all the modules that are loaded behind the scene. You can use the cmdlet Get-Module -ListAvailable to view the list of all available modules. A module is a collection of cmdlets, variables, functions, and workflows. |
Get-PSBreakpoint | gbp | Retrieves all current breakpoints that are set in the current session. This cmdlet can help you debug PowerShell. |
Get-PSCallStack | gcs | Displays the call stack or all commands executed in the current session. With this cmdlet, you can see a history of all commands run as part of a single execution step. |
Get-PSDrive | gdr | Displays the variety of drives exposed by Windows PowerShell in the current session. |
Get-PSSession | gsn | Displays the sessions created in the current Windows PowerShell session on local and remote computers. |
Get-PSSnapIn | gsnp | Displays the Windows PowerShell snap-in. |
Get-Process | ps, gps | Retrieves the list of all running applications and processes on a local or remote computer. It shows the process owner, the process ID, or even where on disk the process is located. |
Get-Service | gsv | Displays the list of all installed services, their status (such as running or stopped), and startup type on a local or remote computer. You can use parameters to include or exclude services. |
Get-Unique | gu | Returns unique items from a sorted list. PowerShell cmdlet Select-Object -Unique does the same job but it’s a bit different because it does not require objects to be pre-sorted. |
Get-Variable | gv | Displays the names and the values of the PowerShell variables in the current console. |
Get-WmiObject | gwmi | Searches for different WMI (Windows Management Instrumentation) classes on a system. Using this cmdlet, you can get any information about a Windows computer and its components. |
Group-Object | group | Groups similar objects together based on common properties. |
Import-Alias | ipal | Imports an alias list from a specified file in PowerShell. |
Import-Csv | ipcsv | Fetch the information contained in a CSV file and create a table-like structure. |
Import-Module | ipmo | Imports modules to the current session. |
Import-PSSession | ipsn | Imports command from a remote computer into the current session. |
Invoke-Command | icm | Runs a command or a script and returns the results as an expression on a local or remote computer. |
Invoke-Expression | iex | Runs a specified string as a command on the local computer. |
Invoke-History | r, ihy | Runs commands from the command history in the current session. |
Invoke-Item | ii | Runs or opens the specified item (depending on the file type) in the program associated with the file type. |
Invoke-RestMethod | irm | Sends HTTP or HTTPS requests using various HTTP methods to REST API endpoints. It is an alternative to Invoke-WebRequest. |
Invoke-WMIMethod | iwmi | Launches a create process WMI(Windows Management Instrumentation) method of the WIN32_Process class. |
Invoke-WebRequest | curl, iwr, wget | Sends HTTP, HTTPS, FTP, and FILE requests to a web page or web service on the Internet. |
mkdir | md | Creates a new directory. |
Measure-Object | measure | Measures how large an object is by calculating the numeric properties of the object in terms of characters, words, and lines. |
Move-Item | mi, mv, move | Moves a file, folder, or registry along with its properties, contents, and child items from one location to another location. |
Move-ItemProperty | mp | Movesthe property of an item from one place to another. |
New-Alias | nal | Creates a new alias. |
New-Item | ni | Creates a new item. |
New-Module | nmo | Creates a dynamic module from a script block. |
New-PSDrive | ndr, mount | Creates a new temporary or persistent drive with various Windows PowerShell provider types. To create a new PSDrive you’ll need to provide a drive name, the provider, and the location. |
New-PSSession | nsn | Creates a persistent connection to a local or remote computer. |
New-PSSessionConfigurationFile | npssc | Creates a persistent PowerShell connection to a local or remote host. |
New-Variable | nv | Creates a new variable by simply assigning it a value. |
Out-GridView | ogv | Displays data as an interactive table (the GUI format) that can be filtered or sorted based on different criteria. |
Out-Host | oh | Sends output to the Windows PowerShell host for display. |
Out-Printer | lp | Sends output to the connected printer. |
Pop-Location | popd | Changes the current location to the path at the top of the directory stack. |
Push-Location | pushd | Pushes or adds the current location to the top of a location stack called ‘Paths’ and sets the C:\Program Files\PowerShell\ directory as the current directory. |
Receive-Job | rcjb | Fetches the results of Windows PowerShell background jobs, such as those started by using the Start-Job cmdlet. |
Receive-PSSession | rcsn | Fetches the results of PowerShell sessions that were disconnected intentionally using the Disconnect-PSSession cmdlet. |
Remove-Item | del, erase, rd, ri, rm, rmdir | Deletes items from specific locations like files, folders, registry keys, variables, and functions. You can use parameters to include or exclude items. You can use this command to delete files with very long names using PowerShell. |
Remove-ItemProperty | rp | Deletesregistry values and stored data of an item. |
Remove-Job | rjb | Deletes a Windows PowerShell background job. Deletes n stopped or completed background job in PowerShell, You need to mention the ‘-id n’ or ‘-name xxx’ to specify the job you want to remove. |
Remove-Module | rmo | Deletes module objects (cmdlets and functions) from the PowerShell session. |
Remove-PSBreakpoint | rbp | Disables the breakpoint from the current console so they are not hit when the script runs. |
Remove-PSDrive | rdr | Removes temporary PowerShell drives created with New-PSDrive. To remove multiple drives together, you should separate them using a comma (,). |
Remove-PSSession | rsn | Closes PowerShell sessions, stops any running commands in the current session, ends the PSSession, and also closes the connection between the local and remote computers. |
Remove-PSSnapin | rsnp | Unloads a snap-in from the current PowerShell session. |
Remove-Variable | rv | Removes the variable and its value defined in PowerShell. |
Remove-WMIObject | rwmi | Removes a WMI (Windows Management Instrumentation) class. |
Rename-Item | ren, rni | Renames items such as files and directories in a PowerShell provider namespace. |
Rename-ItemProperty | rnp | Renames an item’s property without changing its value. |
Resolve-Path | rvpa | Resolves the wildcard characters in a path and displays the items and containers at the location specified by the path. |
Resume-Job | rujb | Resumes a suspended job. |
Select-Object | select | Selects specific properties from an object or dataset. |
Select-String | sls | Searches for text and text patterns in input strings and files. |
Set-Alias | sal | Creates or changes an alias (alternate name) for a cmdlet or other command element in the current PowerShell session. |
Set-Content | sc | Writes or replaces the content in an item with new content. |
Set-Item | si | Changes the value of an item to the value specified in the command. |
Set-ItemProperty | sp | Sets the value of the property of the specified object. |
Set-Location | cd, chdir, sl | Changes the current directory or location to a location you specify. |
Set-PSBreakpoint | sbp | Sets the line breakpoint in the script. |
Set-Variable | set, sv | Assigns a value to a variable or changes the current value. If the specified variable doesn’t exist, the cmdlet will create it. |
Show-Command | shcm | Lets you find the parameters and syntax of other PowerShell cmdlets graphically. |
Sort-Object | sort | Sortsobjects in ascending or descending order based on the values of properties. |
Start-Job | sajb | Starts a Windows PowerShell background job without interacting with the current session. |
Start-Process | saps, start | Startssingle or multiple processes on the local computer. |
Start-Service | sasv | Start one or more stopped services on the system. |
Start-Sleep | sleep | Suspends the activity in a script or session for a certain period of time. |
Stop-Job | spjb | Stops all or stop selected jobs based on their name, ID, instance ID, or state. |
Stop-Process | kill | Forcibly kills or stops the running processes. |
Suspend-Job | sujb | Suspends workflow jobs by temporarily interrupting or pausing them. |
Wait-Job | wjb | Suspends the command prompt until the PowerShell background tasks running in the session are complete. |
Where-Object | ?, where | Filters objects based on their property values. |
Write-Output | echo, write | Sends any object or data type, such as strings, integers, arrays, and complex objects to the next command in the pipeline. |
When delving into the realm of systems administration, it is imperative to acquaint oneself with an extensive range of PowerShell commands and cmdlets. If you think I have missed any essential command in this list, please drop a comment.
FAQs
Windows PowerShell Commands and Cmdlets Cheat Sheet (PDF)? ›
The Get-Command cmdlet gets all commands that are installed on the computer, including cmdlets, aliases, functions, filters, scripts, and applications. Get-Command gets the commands from PowerShell modules and commands that were imported from other sessions.
How do I get a list of all PowerShell commands? ›The Get-Command cmdlet gets all commands that are installed on the computer, including cmdlets, aliases, functions, filters, scripts, and applications. Get-Command gets the commands from PowerShell modules and commands that were imported from other sessions.
What are some examples of common cmdlets in PowerShell? ›Well, as you might expect, there are hundreds of cmdlets available. Some more popular ones include Start-Process, Get-Item, Copy-Item, Remove-Item, Get-ChildItem, etc. There's also the concept of PowerShell scripts. These are files that contain one or more cmdlets, variables, if-then type commands.
What are the three core cmdlets in PowerShell? ›- Get-Command.
- Get-Help.
- Get-Member (covered in chapter 3)
- Get-Command. The Get-Command cmdlet retrieves a list of all the PowerShell commands whose modules have been loaded. ...
- Get-Help. ...
- Get-Process. ...
- Get-Service. ...
- ConvertTo-Html. ...
- Get-ChildItem. ...
- Copy-Item. ...
- Get-History.
Another difference between PowerShell and cmd lies in their usage of them. Cmd is used primarily to execute batch commands and do some primary troubleshooting, whereas PowerShell can be used for executing batch commands as well as administrative purposes. Scripts can also be written in PowerShell to automate the tasks.
What is PowerShell and basic commands? ›It is an open-source command-line shell and scripting language built-in dot net. With the help of PowerShell, the administrator can manage computers from the command line. The Windows PowerShell commands are known as cmdlets, which will help administrators to manage from the command line.
What PowerShell command will list all services? ›To find the service name and display name of each service on your system, type Get-Service . The service names appear in the Name column, and the display names appear in the DisplayName column. When you sort in ascending order by status value, Stopped services appear before Running services.
What are the three basic cmdlets when working with users in PowerShell? ›- Get-Command.
- Get-Help.
- Get-Member.
Cmdlets are lightweight commands used in the PowerShell environment. Most of the cmdlets in PowerShell use the Verb-Noun format. For example, Get-Command, Update-Help, Start-Service, etc. To know more about cmdlets and understand what differentiates them from commands, you can read this link.
What is the difference between a function and a cmdlet? ›
Hence, unlike functions that are integrated PowerShell environment before compiling, cmdlets are . NET classes that are already compiled into “. dll” files so that PowerShell can access them. Like functions, cmdlets can have parameters and return values to display or assign to variables.
How many cmdlets are available in PowerShell? ›Over 200 cmdlets can be used in PowerShell. Windows PowerShell command prompt isn't case-sensitive, so these commands can be typed in either upper or lower case.
How do I see all the commands in PowerShell history? ›Viewing PowerShell Command History on Windows
In the PowerShell console, the last command you typed appears when you press the Up key. If you continue to press the “up” key, you will see all the commands executed earlier.
Over 200 cmdlets can be used in PowerShell. Windows PowerShell command prompt isn't case-sensitive, so these commands can be typed in either upper or lower case.
What is the PowerShell command to display the history of commands executed? ›The Get-History cmdlet gets the session history, that is, the list of commands entered during the current session. PowerShell automatically maintains a history of each session. The number of entries in the session history is determined by the value of the $MaximumHistoryCount preference variable.
Where can I find PowerShell scripts? ›The PowerShell Gallery is the central repository for PowerShell content. In it, you can find PowerShell scripts, modules containing PowerShell cmdlets and Desired State Configuration (DSC) resources.