Windows PowerShell Commands and Cmdlets Cheat Sheet (PDF) (2023)

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.

(Video) Windows PowerShell/Command Line for Beginners (Tutorial)

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.

(Video) 30 Windows Commands you CAN’T live without

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.

(Video) Windows Updates through PowerShell

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.

(Video) 15 Useful PowerShell Commands for Beginners | Learn Microsoft PowerShell

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.

(Video) 40 Windows Commands you NEED to know (in 10 Minutes)

Command name/CmdletAliasDescription
Add-ContentacAdds content to the specified files. For instance, you can add words to a file.
Add-PSSnapInasnpAdds PowerShell snap-ins to the current session.
Clear-ContentclcDeletes the contents of a file while retaining the file.
Clear-HistoryclhyDeletes specific entries from the command history.
Clear-Hostcls, clearRemoves all text (commands and output) from the current display.
Clear-ItemPropertyclpClears the value of a property.
Clear-VariableclvClears the value of a variable.
Compare-Objectcompare, difCompares two sets of objects directly by generating reports on the differences between the objects.
Connect-PSSessioncnsnReconnects to the disconnected sessions.
Copy-Itemcopy, cp, cpiCopiesfiles and folders from a source file path to the destination file path.
Copy-ItemPropertycppCopies the value of a property from a specified location to another location.
Disable-PSBreakpointdbpDisables the breakpoints in the current PowerShell console.
Disconnect-PSSessiondnsnDisconnects from a PowerShell session.
Enable-PSBreakpointebpEnables the breakpoints in the current PowerShell console.
Enter-PSSessionetsnStarts a PowerShell session with a remote computer.
Exit-PSSessionexsnEnds a PowerShell session with a remote computer.
Export-AliasepalExports information about currently defined aliases to a file.
Export-CsvepcsvConverts objects into a series of character-separated values and saves the strings in a CSV file.
Export-PSSessionepsnExports cmdlets and functions from another session on a computer and saves them in a PowerShell module.
ForEach-Object%, foreachPerforms modification or formatting on every item in a specified group of input objects (or items).
Format-CustomfcUses a customized view todisplay objects while retaining their basic structure.
Format-ListflFormats the output of a command as a list of properties, showing each property on a new line.
Format-TableftFormats the output into table form.
Get-AliasgalGets 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-nameor gal -d cmdlet-name.
Get-ChildItemgci, dir, lsGets the files and folders from one or more specified locations, such as a file system directory, registry hive, or certificate store.
Get-CommandgcmDisplays the list of all PowerShell commands and functions.
Get-Contentgc, typeGets the contents from a file without opening it and returns each text file line as a string object.
Get-DateGets the current date and time.
Get-HelpHelps you to get to know all the PowerShellcommands, their parameters, functions, scripts, workflows, etc.
Get-Historyh, ghy, historyDisplays the list of the previous commands used in the current session.
Get-HotFixGets hotfixes or updates that have been installed on either the local computer or remote computer.
Get-ItemgiGets files and folders at the specified location but doesn’t get the contents of the item unless you use a wildcard (*).
Get-ItemPropertygpGetsthe registry entries or values in the readable format in the console.
Get-JobgjbGets the list of jobs running in the background, and those that have completed in the current session.
Get-Locationgl, pwdGets an object that represents the current directory within PowerShell.
Get-MembergmDisplays the properties, methods, and different members of an object.
Get-ModulegmoDisplays 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-PSBreakpointgbpRetrieves all current breakpoints that are set in the current session. This cmdlet can help you debug PowerShell.
Get-PSCallStackgcsDisplays 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-PSDrivegdrDisplays the variety of drives exposed by Windows PowerShell in the current session.
Get-PSSessiongsnDisplays the sessions created in the current Windows PowerShell session on local and remote computers.
Get-PSSnapIngsnpDisplays the Windows PowerShell snap-in.
Get-Processps, gpsRetrieves 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-ServicegsvDisplays 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-UniqueguReturns 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-VariablegvDisplays the names and the values of the PowerShell variables in the current console.
Get-WmiObjectgwmiSearches 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-ObjectgroupGroups similar objects together based on common properties.
Import-AliasipalImports an alias list from a specified file in PowerShell.
Import-CsvipcsvFetch the information contained in a CSV file and create a table-like structure.
Import-ModuleipmoImports modules to the current session.
Import-PSSessionipsnImports command from a remote computer into the current session.
Invoke-CommandicmRuns a command or a script and returns the results as an expression on a local or remote computer.
Invoke-ExpressioniexRuns a specified string as a command on the local computer.
Invoke-Historyr, ihyRuns commands from the command history in the current session.
Invoke-ItemiiRuns or opens the specified item (depending on the file type) in the program associated with the file type.
Invoke-RestMethodirmSends HTTP or HTTPS requests using various HTTP methods to REST API endpoints. It is an alternative to Invoke-WebRequest.
Invoke-WMIMethodiwmiLaunches a create process WMI(Windows Management Instrumentation) method of the WIN32_Process class.
Invoke-WebRequestcurl, iwr, wgetSends HTTP, HTTPS, FTP, and FILE requests to a web page or web service on the Internet.
mkdirmdCreates a new directory.
Measure-ObjectmeasureMeasures how large an object is by calculating the numeric properties of the object in terms of characters, words, and lines.
Move-Itemmi, mv, moveMoves a file, folder, or registry along with its properties, contents, and child items from one location to another location.
Move-ItemPropertympMovesthe property of an item from one place to another.
New-AliasnalCreates a new alias.
New-ItemniCreates a new item.
New-ModulenmoCreates a dynamic module from a script block.
New-PSDrivendr, mountCreates 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-PSSessionnsnCreates a persistent connection to a local or remote computer.
New-PSSessionConfigurationFilenpsscCreates a persistent PowerShell connection to a local or remote host.
New-VariablenvCreates a new variable by simply assigning it a value.
Out-GridViewogvDisplays data as an interactive table (the GUI format) that can be filtered or sorted based on different criteria.
Out-HostohSends output to the Windows PowerShell host for display.
Out-PrinterlpSends output to the connected printer.
Pop-LocationpopdChanges the current location to the path at the top of the directory stack.
Push-LocationpushdPushes 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-JobrcjbFetches the results of Windows PowerShell background jobs, such as those started by using the Start-Job cmdlet.
Receive-PSSessionrcsnFetches the results of PowerShell sessions that were disconnected intentionally using the Disconnect-PSSession cmdlet.
Remove-Itemdel, erase, rd, ri, rm, rmdirDeletes 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-ItemPropertyrpDeletesregistry values and stored data of an item.
Remove-JobrjbDeletes 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-ModulermoDeletes module objects (cmdlets and functions) from the PowerShell session.
Remove-PSBreakpointrbpDisables the breakpoint from the current console so they are not hit when the script runs.
Remove-PSDriverdrRemoves temporary PowerShell drives created with New-PSDrive. To remove multiple drives together, you should separate them using a comma (,).
Remove-PSSessionrsnCloses 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-PSSnapinrsnpUnloads a snap-in from the current PowerShell session.
Remove-VariablervRemoves the variable and its value defined in PowerShell.
Remove-WMIObjectrwmiRemoves a WMI (Windows Management Instrumentation) class.
Rename-Itemren, rniRenames items such as files and directories in a PowerShell provider namespace.
Rename-ItemPropertyrnpRenames an item’s property without changing its value.
Resolve-PathrvpaResolves the wildcard characters in a path and displays the items and containers at the location specified by the path.
Resume-JobrujbResumes a suspended job.
Select-ObjectselectSelects specific properties from an object or dataset.
Select-StringslsSearches for text and text patterns in input strings and files.
Set-AliassalCreates or changes an alias (alternate name) for a cmdlet or other command element in the current PowerShell session.
Set-ContentscWrites or replaces the content in an item with new content.
Set-ItemsiChanges the value of an item to the value specified in the command.
Set-ItemPropertyspSets the value of the property of the specified object.
Set-Locationcd, chdir, slChanges the current directory or location to a location you specify.
Set-PSBreakpointsbpSets the line breakpoint in the script.
Set-Variableset, svAssigns a value to a variable or changes the current value. If the specified variable doesn’t exist, the cmdlet will create it.
Show-CommandshcmLets you find the parameters and syntax of other PowerShell cmdlets graphically.
Sort-ObjectsortSortsobjects in ascending or descending order based on the values of properties.
Start-JobsajbStarts a Windows PowerShell background job without interacting with the current session.
Start-Processsaps, startStartssingle or multiple processes on the local computer.
Start-ServicesasvStart one or more stopped services on the system.
Start-SleepsleepSuspends the activity in a script or session for a certain period of time.
Stop-JobspjbStops all or stop selected jobs based on their name, ID, instance ID, or state.
Stop-ProcesskillForcibly kills or stops the running processes.
Suspend-JobsujbSuspends workflow jobs by temporarily interrupting or pausing them.
Wait-JobwjbSuspends the command prompt until the PowerShell background tasks running in the session are complete.
Where-Object?, whereFilters objects based on their property values.
Write-Outputecho, writeSends any object or data type, such as strings, integers, arrays, and complex objects to the next command in the pipeline.
(Video) PowerShell Tutorials : Reading PDF files

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.

(Video) LAB GUIDE:26 How to Run PowerShell Commands on Remote Computers

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? ›

The Three Core Cmdlets in PowerShell
  • Get-Command.
  • Get-Help.
  • Get-Member (covered in chapter 3)
Dec 14, 2022

What commands are used in PowerShell? ›

Here are 12 of the more widely used PowerShell cmdlets.
  • 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.
Mar 8, 2023

What is the difference between command prompt and PowerShell commands? ›

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? ›

To that end, in this article I describe three core PowerShell cmdlets:
  • Get-Command.
  • Get-Help.
  • Get-Member.
Mar 25, 2015

What is an example of a cmdlet? ›

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.

How many commands are there 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.

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.

Videos

1. PowerShell Tutorials : Reading PDF files
(JackedProgrammer)
2. LAB GUIDE:26 How to Run PowerShell Commands on Remote Computers
(Must be Noob)
3. PowerShell 7 Tutorials for Beginners : Fundamentals
(JackedProgrammer)
4. Create Files and Folders in Powershell
(MrPowerScripts)
5. 15 Command Prompt Secrets and Tricks in Windows
(ThioJoe)
6. How to Optimise your PC with these Windows Powershell Scripts
(NotroDan)
Top Articles
Latest Posts
Article information

Author: Nathanial Hackett

Last Updated: 11/10/2023

Views: 6529

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Nathanial Hackett

Birthday: 1997-10-09

Address: Apt. 935 264 Abshire Canyon, South Nerissachester, NM 01800

Phone: +9752624861224

Job: Forward Technology Assistant

Hobby: Listening to music, Shopping, Vacation, Baton twirling, Flower arranging, Blacksmithing, Do it yourself

Introduction: My name is Nathanial Hackett, I am a lovely, curious, smiling, lively, thoughtful, courageous, lively person who loves writing and wants to share my knowledge and understanding with you.