Windows PowerShell Commands Cheat Sheet (PDF), Tips, and Lists (2023)

  1. network administrator
  2. Windows PowerShell command cheat sheet

We are funded by our readersand you may receive a commission if you make purchases through links on our site.

We explain what Windows PowerShell is and provide you with a definitive download.PowerShell command cheat sheet(PDF) as a quick reference to get started and run your own commands.

Tim Carey Network administration specialist

UPDATED:March 31, 2022

When it comes to running commands in Windows, PowerShell has become a trump card. For years, enthusiasts were limited to the confines of the Windows command line, but in 2006, PowerShell emerged as a powerful alternative.

Was ist Windows PowerShell?

Power Shellis interactivecommand line interface(CLI) and automation engine developed by Microsoft to design system configurations and automate management tasks.

This tool has its own command line with a unique Perl-like programming language. PowerShell was originally developed to manage objects on users' computers.

Today, PowerShell provides users with a comprehensive environment in which to perform and automate system administration tasks. The user can programmatically access resources from Active Directory to Exchange Server. Essentially, PowerShell allows the user to access:

  • command soon
  • PowerShell Commands
  • API von .NET Framework
  • Windows Management Instrumentation
  • Windows Component Object Model

Since PowerShell has become an open-source application, Linux and Unix-based users can now access this versatile platform. PowerShell is mainly used to help users automate administrative work. Instead of performing tedious and repetitive tasks, the user can simply create scripts and issue commands, and PowerShell will complete them automatically. The user can customize hundreds of commands, calledCmdlets.

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

Microsoft PowerShell Download PowerShell - latest stable version

List of PowerShell commands

Here are 25 basic PowerShell commands:

command namePseudonymdescription
choose placecd, chdir, slSets the current work location to a specific location.
get the contentCat, GC, typeGets the content of the element at the specified position.
add contentC.AAdd content to specific elements, e.g. B. adding words to a file.
set contentSouth CarolinaWrite or replace the content of an element with new content.
copy itemcopy, cp, cpiCopies an item from one location to another.
remover itemdel, turn off, rd, ri, rm, rmdirExcludes the specified items.
movement elementmi, motor, mvMoves an item from one location to another.
set of elementsmiChanges the value of an item to the value specified in the command.
new itemInsideCreate a new item.
Start-JobAhaStarts a Windows PowerShell background job.
comparison objectcompare, diffCompare two sets of objects.
group objectgroupGroups objects that contain the same value for specified properties.
Invoke-WebRequestrizo, ywr, wgetRetrieves the content of a web page on the Internet.
Measure Objectmeasure upCalculates numeric properties of objects and characters, words and lines in string objects such as files...
walkthroughrvpaResolves wildcards in a path and displays the contents of the path.
curriculum workRujbRestarts a suspended job
variable setdefine, svSets the value of a variable. Creates the variable if none with the requested name exists.
show commandschcmCreate Windows PowerShell commands in a graphical command window.
sort objectto organizeSorts objects by property values.
start the servicesasvStarts one or more stopped services.
Start progressjuice, beginningStarts one or more processes on the local computer.
work suspendedsujbTemporarily stops workflow jobs.
job on holdwjbSuppresses the command prompt until one or all of the Windows PowerShell background jobs running in the session...
where object?, WoSelects objects from a collection based on their property values.
record outputwrite echoSends the specified objects to the next command in the pipeline. If the command is the last command in the pipeline...

PowerShell-Spickzettel (PDF)

Get the PDF version of our PowerShell cheat sheet.

Windows PowerShell Commands Cheat Sheet (PDF), Tips, and Lists (2)

How to use Windows PowerShell

PowerShell is ideal for enterprise administrators who perform complex management operationslarge corporate networks🇧🇷 Instead of collecting information about hundreds of different servers and services manually (which would take a lot of time), you can just run a PowerShell script to provide you with the information automatically.

In general, PowerShell is most beneficial for users with prior command-line experience. To use PowerShell, you can run a variety of .NET cmdlets, scripts, executables, and classes. For the purposes of this article, we'll mainly focus on cmdlets and scripts to help you understand the basics.

Udemy has severaltop rated courses in PowerShellthat you may find useful.

PowerShell vs Command Prompt

For many users, PowerShell is a better alternative to Command Prompt. The reason is that it simply has more power. One of the biggest differences is that PowerShell uses cmdlets instead of commands. Cmdlets bring Registry Management and Windows Management Instrumentation within users' administrative reach. In contrast, Command Prompt is limited to much simpler commands.

There is some syntax overlap between the two platforms as PowerShell accepts some command prompt commands likeipconfigtocd🇧🇷 However, they are referred to as aliases instead of cmdlets. Another key difference is that PowerShell is object-centric. Any part of a cmdlet's output is an object instead of text. This makes it easier for the user to navigate through complex data. The inclusion of the .NET framework also allows PowerShell scripts to use .NET interfaces. In short, PowerShell is a command prompt for steroids.

Cargondo PowerShell

Before we dive into the basics of using PowerShell, you need to get to the main interface first. If you are a Windows 10 user, you already have access to PowerShell 5. Windows 8-8.1 users have access to PowerShell 4, but if you have Windows 7, you must do soinstall on pcwithin a .NET framework. On all operating systems, PowerShell offers two different interfaces.

The most advanced is the Integrated Scripting Environment, which acts as a full GUI for advanced users. The basic alternative is the PowerShell console, which provides a command line for the user to enter their commands. Beginners are advised to stick with the latter until they learn the basics of PowerShell.

To start PowerShell in Windows 10, you must be an administrator. Log in as an administrator, clickBeginand scroll through your apps until you find themWindows PowerShell🇧🇷 Right click and selectExecute as administrator🇧🇷 In Windows 8.1, just search for PowerShell in yourSystemBinder. Similarly, on Windows 7, the default PowerShell directory isAccesoriesFolder after installing the program.

What are the ways to run PowerShell as an administrator?

  1. Press WIN + R, enterPower Shell, press Ctrl+Shift+Enter. clickOKexecute as administrator.
  2. Type powershell in the search box on the taskbar. chooseExecute as administratorin the list of options in the right pane of the results list.
  3. Open command prompt, typegrenade power,and press Enter. modelPowershell start process -verb runasand press Enter.
  4. Also type at the command promptPeople /netonly /user:remote domain\ Administrator oder Powershell(substitute a URL or hostname for RemoteDomain)

A note on option 4 on this list:

Ö/netonlyoption fromRodeapplies a user account to remote targets. So in this case you want to run PowerShell as an administrator on a computer identified by RemoteDomain. The administrator account is active on this remote device and not on the local computer. Therefore, when prompted, enter the password for the administrator account, not the password for the administrator account on the local computer.

how to run cmdlets

In short, onecmdletis a single function command. Type cmdlets at the command line, just like you would with a traditional command or utility. Cmdlets are the primary way to interact with the CLI.

In PowerShell, most cmdlets are written in C# and are instructions for running a function that returns a .NET object.

More than 200 cmdlets can be used in PowerShell. The Windows PowerShell prompt is case-insensitive, so these commands can be entered in either uppercase or lowercase. The main cmdlets are listed below:

  • get location– Get current directory
  • choose place– Get current directory
  • moving company element- Move a file to a new location
  • copy item- Copy a file to a new location
  • rename– item Rename an existing file
  • new item- Create a new file

For a full list of available commands, seeget commandcmdlet. At the command line you would type:

(Video) Basic Powershell Commands For Beginners

PS C:\> Get command

It's important to note that Microsoft prevents users from using custom PowerShell cmdlets in their default configurations. To use the PowerShell cmdlets, you must have theexecution policysinceRestrictedthroughRemoteSigned.signed removalThis allows you to run your own scripts, but prevents unsigned scripts from other users.

To change your execution policy, enter the following PowerShell command:

PS C:\> Set execution policy

switch toRemoteSigned, enter the following command:

PS C:\> Establecer-ExecutionPolicy -ExecutionPolicy RemoteSigned

Make sure you have an administrator account to have permission to set a new execution policy.

How to run PowerShell scripts

Script-based commands and processes are part of the foundation of PowerShell's versatility. In PowerShell, a script is essentially a text file with a ps1 extension in the filename. To create a new script, just open Windows Notepad, type your commands, and save it with ".ps1" at the end of the name.

To run a script, enter its folder and filename in the PowerShell window:

PD c:\powershell\mynewscript.ps1

After that, the selected script will be executed.

Want to create your own PowerShell scripts?Almost 5,000 students have already taken partThis Udemy course on Advanced Scripting with PowerShell.

Overlay with Windows commands

If you're new to PowerShell, learning a whole new command library can be difficult. However, what most new users don't realize is that the syntax used in the Windows command line overlaps with PowerShell. This is made easier by the fact that PowerShell is not case sensitive.

Like the command prompt in PowerShell, theCDthe command still changes the directory, anddirectoryIt even provides a list of files in the selected folder. So it's important to remember that you're not necessarily starting from scratch. Keeping this in mind can shorten the learning curve when using PowerShell and reduce the number of new commands you have to learn.

However, it is important to note that these are not considered full PowerShell commands, but rather aliases (the Powershell name for Windows command prompt commands). So while you can try out some of the Command Prompt commands in PowerShell, you should learn as much as you can about the new ones. However, the Command Prompt experience can definitely help new users get comfortable with PowerShell and get started.

Backup a SQL database with PowerShell

Many people use PowerShell to backup SQL databases. The command line interface can perform full database backups, file backups, and transaction log backups. There are many ways to backup a database in PowerShell, but one of the easiest is to use theBackup-SqlDatabaseDomain. For example:

PS C:\> Backup-SqlDatabase -ServerINstance „Computer\Instance“ -Datenbank „Databasecentral“

This will create a database backup of a database named "Databasecentral" (or the name of your chosen database).

To back up a transaction log, you must enter the following:

PS C:\> Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "Databasecentral" -BackupAction Log

This creates a transaction log for the selected database.

The essential PowerShell commands

Using aliases will only get you limited in PowerShell, so it's important to learn as much as you can about native PowerShell commands. We've covered a few of these above, but we'll detail the most important ones below.

get help

This command should be at the top of every new user's list when it comes to PowerShell. The Get-Help command can be used to get help on literally any other PowerShell command. For example, if you know the name of a command but don't know what it does or how to use it, the Get-Help command provides the complete syntax for the command.

For example, if you want to see how Get-Process works, type:

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

PS C:\>Get-Help-Name Get-Process
PS C:\> Set execution policy

As mentioned earlier in this guide, Microsoft has a strict execution policy that prevents scripting in PowerShell unless you change it. When configuring the execution policy, you have four options to choose from:

  • Restricted– The default execution policy that stops the scripts from running.
  • all signed- Runs scripts if they are signed by a trusted publisher
  • signed removal- Allows execution of scripts created locally
  • unrestricted– An unrestricted script execution policy
PS C:\> Get-ExecutionPolicy

When using PowerShell, you may not always be working on a server that you are familiar with. Executing the commandGet Execution Policyyou can see which policy is active on the server before running a new script. If you see that the server in question is operating under a strict policy, you can implement itEstablecer-ExecutionPolicycommand to change it.

get service

One of the most important commands isget service, which provides the user with a list of all services installed on the system, both running and stopped. This cmdlet can be addressed by specific names or service objects.

For example when you writePS C:\> Get service, you will see a list of all the services on your computer, their status and friendly names.

To use this command to get specific services, type:PS C:\ Get service "WMI*"to get all services that start with WMI.

If you want to limit the output to active services on your computer, enter the following command:

PD C:\ Get Service | Where-Object {$_.Status -eq "Running"}

Convert to HTML

If you're using PowerShell, you might want to create a report of the information that's displayed. One of the best ways to do this is by usingConvert to HTMLDomain. This cmdlet allows you to create reports with tables and colors that can help you visualize complex data. Just select an object and add it to the command. For example, you could write:

Get PSDrive | Convert to HTML

This returns a lot of information, so it's a good idea to limit this to one file using the out-file command. A better alternative command is:

Get-PSD Unit | Convert to HTML | Output File - FilePath PSDrives.html

This generates an HTML file in the form of a table. For example:

You can add your own colors and borders to refine your presentation.

Export-CSV (e Get-Service)

No less important to increase visibility is the export CSV command. Allows data to be exported from PowerShell to a CSV file. Essentially, this command creates a CSV file that compiles all of the objects you've selected in PowerShell. Each object has its own row or line within the CSV file. This command is mainly used to create spreadsheets and share data with external programs.

To use this command, you would type:

PD C:\> Get Service | Export CSV c:\service.csv

It is important to remember not to format objects before running the export csv command. This is because object formatting results in only the formatted properties being placed in the CSV file and not the original objects themselves. If you want to send specific properties of an object to a CSV file, you must use theselect objectcmdlet.

use theselect objectCmdlet, Typ:

PS C:\> Get Service | Choose object name, status | Export CSV c:\Service.csv

get process

If you want to see all the processes currently running on your system, you can use theget processCommand is very important. To get a list of all active processes on your computer, type:

PS C:\ Get Process

Please note that if you do not specify any parameters, you will receive an analysis of all active processes on your computer. To select a specific process, narrow the results by process name or ID and combine them with theList of FormatsCmdlet that shows all available properties. For example:

PD C:\ Get-Process windowrd, Explorer | Liste der Formate *

This enables comprehensive monitoring of all active processes.

Get event log

If you want to access your computer's event logs (or logs on remote computers) while using PowerShell, you need theGet event logDomain. This cmdlet only works with classic event logs, so you need theGet-WinEventCommand for registries after Windows Vista.

(Video) PowerShell Tutorials : Reading PDF files

To run the event log command, type:

PS C:\> Get-EventLog-Liste

This will display all event logs on your computer.

One of the most common reasons users look at event logs is to spot errors. If you want to see error events in your log, just type:

PS C:\> Get-EventLog -LogName System -EntryType Error

If you want to receive event logs from multiple computers, specify which devices you want to see (listed below as "Server1" and "Server2"). For example:

PS C:\> Get-EventLog - LogName "Windows PowerShell" -ComputerName "computadora local", "Servidor1", "Servidor2".

The parameters you can use to search for event logs include:

  • later– The user specifies a date and time, and the cmdlet finds events that occur after that
  • comoBaseObject- Provides a System.Diagnostics.EventLogEntry for each event
  • like rope- Returns the output as strings
  • before- The user provides a date and time and the cmdlet finds events that have occurred previously
  • Computername- Used to refer to a remote computer
  • input type- Indicates the type of event input (Error, Check Failed, Check Passed, Informational, Warning)
  • Index- Specifies index values ​​at which the cmdlet finds events
  • List- Provides a list of event logs
  • username- Specifies usernames associated with a specific event

stop process

When using PowerShell, it's not uncommon for a process to hang. Whenever this happens, you can useget processto get the name of the process in need and then stop it with thestop processDomain. Generally, you complete a process on your behalf. For example:

PD C:\> Stop Process -Name "notepad"

In this example, the user ended the notebook withstop processDomain.

PowerShell: a powerful command line interface

While the transition to PowerShell may seem quite complex, the command line interface works like any other. You can use your own unique cmdlets, but a variety of online resources can help you with any management task you can think of. To get the most out of PowerShell, all you have to do is get used to the variety of commands available.

As a new user, it's easy to get intimidated by PowerShell's 200+ cmdlets. Make sure you start with the command line interface before moving on to the full GUI. Whether you're new to PowerShell or new to command-line interfaces, there's more than enough information available online to help you get the most out of this powerful tool.


Frequently asked questions about PowerShell commands

How do I navigate Windows PowerShell?

The main navigation actions you need to know for PowerShell are logging in and logging out again. The easiest way to access the PowerShell environment is by typingPower Shellin the search box on the taskbar. PowerShell runs in its own window, so you can close it just by clicking the buttonXin the upper right corner of the window frame. The correct way to close the window is to writeSalidaand the command prompt. The standard Command Prompt navigation commands work in PowerShell, so useCDto change directory. Enter a drive letter followed by a colon (ex.D:) to switch to another unit.

Is Windows PowerShell the same as Command Prompt?

PowerShell is an evolution over Command Prompt because its shell scripting capabilities include better scripting constructs than are available for batch jobs at Command Prompt. All Command Prompt commands are available in PowerShell, but PowerShell has additional commands and utilities called cmdlets. Think of PowerShell as Command Prompt+.

How to learn bash script?

Bash scripting is a Unix shell script. Because Linux is an adaptation of Unix, a shell script written for Linux is often referred to as a bash script. There are many online tutorials for creating a bash script. To avoid confusion, try not to call a PowerShell script a bash script.

How can I set Command Prompt as default instead of PowerShell?

When you press WIN + X, you now get a PowerShell window instead of the old command prompt. To continue using Command Prompt, go to the Start menu and clickThe definition🇧🇷 Select Settings from the menupersonalization🇧🇷 Choosetaskbarin the menu on the left side of the personalization settings window. Search in the main area of ​​this windowReplace Command Prompt with Windows PowerShell in the menu when you right-click the Start button or press Windows key + X🇧🇷 Set thisOut of.

What are the ways to run PowerShell as an administrator?

  1. Press WIN + R, enterPower Shell, press Ctrl+Shift+Enter. clickOKexecute as administrator.
  2. Type powershell in the search box on the taskbar. chooseExecute as administratorin the list of options in the right pane of the results list.
  3. Open command prompt, typegrenade power,and press Enter. modelPowershell start process -verb runasand press Enter.
(Video) 3 Things You Didn't Know about Windows Command Prompt

How do I run PowerShell commands?

You can run PowerShell commands in a command prompt window in the following format:Powershell-Befehl "<Powershell-Code>"However, enclose the PowerShell command in quotation marks<PowerShell-Code>🇧🇷 If the PowerShell command requires a quoted value, use single quotes instead of double quotes. The surrounding quotation marks in the example performed here should remain double quotation marks.


1. PowerShell For Beginners Full Course | PowerShell Beginner tutorial Full Course
(Nerd's lesson)
2. Learn and use PowerShell with just three commands - OLD
3. Windows Powershell vs Command Prompt: What's The Difference Anyway?
4. The 2 Most Important Windows Commands
5. 15 CMD Commands Every Windows User Should Know
6. Hacking with Windows Powershell!
(Mile2 - Cyber Security Certifications)
Top Articles
Latest Posts
Article information

Author: Rev. Leonie Wyman

Last Updated: 03/10/2023

Views: 6063

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Rev. Leonie Wyman

Birthday: 1993-07-01

Address: Suite 763 6272 Lang Bypass, New Xochitlport, VT 72704-3308

Phone: +22014484519944

Job: Banking Officer

Hobby: Sailing, Gaming, Basketball, Calligraphy, Mycology, Astronomy, Juggling

Introduction: My name is Rev. Leonie Wyman, I am a colorful, tasty, splendid, fair, witty, gorgeous, splendid person who loves writing and wants to share my knowledge and understanding with you.