15 Essential PowerShell commands every Windows 11 users should know

PowerShell basic commands
(Image credit: Mauro Huculak)

On Windows 11, PowerShell is a command-line interface (CLI) developed by Microsoft to execute commands and run scripts. In a way, it's similar to Command Prompt, but this CLI offers more tools and flexibility, and it's available beyond Windows, including on Linux and macOS.

Although PowerShell contains countless commands to perform actions and manipulate objects (also referred to as "cmdlets"), there are some essential ones you should know regardless of your technical level, as you'll find yourself typing them many times, especially when creating PowerShell scripts.

In this how-to guide, I'll outline the basic PowerShell cmdlets I believe everyone should know. If you're a beginner, these commands will be new to you. If you're a tech-savvy user, you may learn something new, but it can also be a reminder of commands you probably forgot.

PowerShell essential cmdlets for Windows 11

This list includes the most basic commands I believe every user should know. (The list is not arranged in any particular order.)

To use these commands, open Start, search for and launch the Windows Terminal, and launch a PowerShell console (if applicable).

1. Get-help

The "Get-Help" cmdlet provides assistance and information about various aspects of the PowerShell environment. For example, it retrieves details for a specific command, function, and script.

Usage:

  • Get-Help CMDLET-NAME
  • Example 1: Get-Help Get-Process – Gets basic help for the specified cmdlet, but you can also specify a function or script.
  • Example 2: Get-Help Get-Process -Full – Gets more details for the Get-Process cmdlet.
  • Example 3: Get-Help Get-Process - Parameter Name – Retrieves details about the "Name" option for the "Get-Process" cmdlet.
  • Example 4: Get-Help Get-Process -Online – Opens the Microsoft support pages with information about a specified cmdlet, function, or script.

(Image credit: Mauro Huculak)

2. Get-Command

The "Get-Command" cmdlet allows you to discover and explore the available commands within the PowerShell environment.

Usage:

  • Get-Command
  • Example 1: Get-Command Get-* – Lists all commands that start with "Get-".
  • Example 2: Get-Command -CommandType Cmdlet – Lists all cmdlets available. You can change the cmdlet for "Alias" or "Function."
  • Example 3: Get-Command -Name "Copy-Item" -Module Microsoft.PowerShell.Management – Finds the "Copy-Item" cmdlet within the module source "Microsoft.PowerShell.Management."

(Image credit: Mauro Huculak)

Key parameters:

  • -Name: Specifies the name of the command you're looking for, and you can even use wildcards like "*".
  • -CommandType: The option filters results based on the command type (for example, cmdlet, function, and alias).
  • -Module: Restricts the search to a specific module.

3. Get-ChildItem (dir, ls, gci)

The "Get-ChildItem" command is equivalent to "dir" in PowerShell, and it allows you to list and manage items within various locations, such as file system directories, registry hives, or certificate stores.

Usage:

  • Get-ChildItem
  • Example 1: Get-ChildItem -Path C:\ – Lists all files and directories in the root of the main installation drive.
  • Example 2: Get-ChildItem -Path C:\Windows\ -Filter *.exe – Retrieves a list of all executable files inside the "Windows" directory.
  • Example 3: Get-ChildItem -Path C:\Users\ -Recurse – Retrieves a list of all the files inside the "Users" directory and subdirectories.
  • Example 4: Get-ChildItem -Path C:\ -Include *.txt,*.docx– Retrieves a list of all files with the ".txt" and ".docx" extensions from the specified location.

(Image credit: Mauro Huculak)

Key parameters:

  • -Path: Specifies the location where items can be retrieved.
  • -Filter: This option filters items based on their names (for example, "*.txt" for all files with the ".txt" extension).
  • -Include: Specifies patterns to include (for example, "*.txt" and "*.docx").
  • -Exclude: Specifies patterns to exclude (for example, "*.txt").
  • -Recurse: Retrieves items from all subdirectories within the specified location.
  • -Depth: Limits the depth of recursion.
  • -Force: Includes hidden and system items.

4. Get-Process (gps, ps)

The "Get-Process" command retrieves information about the processes running on the computer. Similar to Task Manager, the command can retrieve process name, ID (PID), handles, memory and CPU usage, start time, and user account.

Usage:

  • Get-Process
  • Example 1: Get-Process -Name notepad Retrieves the process for the Notepad app.
  • Example 2: Get-Process -Id 13616 Retrieves the process with the "13616" identification number.

(Image credit: Mauro Huculak)

Key parameters:

  • -Name: Specifies the name of the process to retrieve, and it even supports wildcards like "*."
  • -Id: Specifies the process's "Process ID" (PID) to retrieve.

Related cmdlets:

  • Stop-Process: Terminates running processes by specifying their name or process ID, aiding in managing unresponsive applications. For example, Stop-Process -Name 'notepad'
  • Start-Process: Starts processes by specifying their name or process ID. For example, Start-Process -Name 'notepad'

5. Copy-Item (cp, copy, cpi)

The "Copy-Item" command allows you to copy files and directories from one location to another with different options.

Usage:

  • Copy-Item -Path SOURCE -Destination DESTINATION
  • Example 1: Copy-Item -Path "C:\Users\UserDemo\Documents\myFile.txt" -Destination "D:\Backup" – Copies the "myFile.txt" as a single file to the "Backup" folder.
  • Example 2: Copy-Item -Path "C:\Users\UserDemo\Documents" -Destination "D:\Backup\Files" -Recurse – Copies the directory and its contents to the "Files" folder.
  • Example 3: Copy-Item -Path "C:\Logs" -Destination "D:\Backups\Files" -Recurse -Filter "*.log" – Copies only files with a specific extension to the "Files" directory.

(Image credit: Mauro Huculak)

Key parameters:

  • -Path: Specifies the source path of the items to be copied.
  • -Destination: Specifies the destination path for the copied items.
  • -Recurse: Copies all subdirectories within the source directory.
  • -Force: Overwrites existing files at the destination (if necessary).
  • -Filter: Specifies a filter to include or exclude specific files based on their names (for example, "*.txt").

6. Remove-Item (rm, del, erase, ri, rmdir)

In PowerShell, the "Remove-Item" command has been designed to delete files, directories, and other items within your system from other providers, such as the Registry, certificate store, and environment variables. This is the equivalent of the "del" command in Command Prompt.

Usage:

  • Remove-Item -Path SOURCE-FILE
  • Example 1: Remove-Item -Path "C:\Users\UserDemo\Documents\myFile.txt" – Deletes only the "myFile.txt" from the "Documents" folder.
  • Example 2: Remove-Item -Path "C:\MyFiles" -Recurse – Deletes a directory and all its content.
  • Example 3: Remove-Item -Path "C:\Users\UserDemo\Documents" -Recurse -Include "*.docx" – Removes the files with the ".docx" extension from the "Documents" folder.

(Image credit: Mauro Huculak)

Key parameters:

  • -Path: Specifies the path of the items to be deleted.
  • -Recurse: Deletes all subdirectories within the specified directory.
  • -Force: Overwrites read-only attributes and deletes hidden or system files.
  • -Confirm: Prompts for confirmation before deleting each item.
  • -WhatIf: Simulates the deletion operation without deleting any of the items.

7. New-Item (ni)

The "New-Item" cmdlet helps you to create new items within your system, such as files, directories, registry keys, and more.

Usage:

  • New-Item -Path PATH\FOLDER-NAME -ItemType Directory
  • Example 1: New-Item -Path "C:\Random\FileBackup" -ItemType Directory – Creates a new directory (or folder) as indicated in the path of the specified location.
  • Example 2: New-Item -Path "C:\Random\myFile.txt" -ItemType File -Value "This text will be printed inside the text file." – Creates a text file on the specified location and adds the "This text will be printed inside the text file" content into the file.
  • Example 3: New-Item -Path "C:\Random\myFile.txt" -ItemType File – Creates an empty text file on the specified location.
  • Example 4: New-Item -Path "HKCU:\Software\MyApp" -ItemType RegistryKey – Creates a new Registry entry in the specified location.

(Image credit: Mauro Huculak)

Key parameters:

  • -Path: Specifies the location where the new item will be created.
  • -ItemType: Specifies the type of item to create (for example, "File," "Directory," or "RegistryKey").
  • -Name: Specifies the name of the new item that the command will create.
  • -Value: Specifies the initial content of the file.
  • -Force: Overwrites existing items (if necessary).

8. Get-Service (gsv)

The "Get-Service" cmdlet lets you retrieve details about the services running on your computer. Some of the information includes service and display names, status, start type, and dependencies.

Usage:

  • Get-Service
  • Example 1: Get-Service -Name "Spooler" – Retrieves the "Spooler" service.
  • Example 2: Get-Service -DisplayName "Windows Audio" – Retrieves the "Windows Audio" service.

(Image credit: Mauro Huculak)

Key parameters:

  • -Name: Specifies the name of the service to retrieve (supports wildcards).
  • -DisplayName: Specifies the display name of the service.
  • -ComputerName: Specifies the remote computer from which to retrieve services.
  • -Include: Specifies patterns to include (for example, "Win*").
  • -Exclude: Specifies patterns to exclude (for example, "SQL*").

Related cmdlets:

  • Start-Service: Starts a stopped service, enabling the activation of necessary system services. For example, Start-Service -Name 'wuauserv'
  • Stop-Service: Stops a running service, allowing for the cessation of unnecessary or problematic services. For example, Stop-Service -Name 'wuauserv'

9. Clear-Host (cls, clear)

The "Clear-Host" cmdlet clears the contents of the current console window, similar to the "cls" command from the Command prompt.

Usually, you would use this command to clean the clutter and improve the readability of the console, especially after executing multiple commands or viewing lengthy output.

Usage:

  • Clear-Host

(Image credit: Mauro Huculak)

10. Set-Location (cd, chdir)

The "Set-Location" cmdlet lets you change the current working directory, similar to the "cd" command from Command Prompt.

Usage:

  • Set-Location PATH
  • Example 1: Set-Location C:\ – Navigates to the root of the "C" drive.
  • Example 2: Set-Location .. – Moves one level up in the directory hierarchy (equivalent to "cd ..").

(Image credit: Mauro Huculak)

11. Get-History (ghy, h)

The "Get-History" command retrieves a list of the commands you have previously entered in the current session. In other words, this cmdlet allows you to easily re-execute previous commands without having to retype them.

Usage:

  • Get-History
  • Example 1: Get-History -Count 10 – Displays the last 10 commands entered.
  • Example 2: Get-History -Id 123 – Displays the command with the ID 123.

(Image credit: Mauro Huculak)

You can also use the "$MaximumHistoryCount" option to control the maximum number of commands PowerShell stores in its command history. Starting with PowerShell 3.0, the default value is 4096, meaning the shell will remember the last 4096 commands you typed. However, you can run the $MaximumHistoryCount = 32767 to set it to the maximum number.

12. Get-Content (gc, cat, type)

The "Get-Content" command can read and output the contents of files or other data sources. This cmdlet not only comes in handy to read a text file in the command console, but it's also useful to read the contents of a log file.

Usage:

  • Get-Content -Path PATH-AND-FILENAME
  • Example 1: Get-Content -Path "C:\Folder\myFile.txt" – Reads the content of "myFile.txt" and displays each line on a separate line in the console.
  • Example 2: $fileContent = Get-Content -Path "C:\Folder\myFile.txt" – Reads the content of "myFile.txt" and stores it in the variable $fileContent.
  • Example 3: Get-Content -Path "C:\Folder\myFile.txt" -Raw – Reads the entire content of "myFile.txt" as a single string.
  • Example 4: Get-Content -Path "C:\Folder\myFile.txt" -TotalCount 5 – Reads the first five lines of "myFile.txt."
  • Example 5: Get-Content -Path "C:\Folder\myFile.txt" -Tail 3 – Reads the last three lines of "myFile.txt."

(Image credit: Mauro Huculak)

Key parameters:

  • -Path: Specifies the path to the file or other data source.
  • -Raw: Reads the entire file content as a single string instead of an array of lines.
  • -TotalCount: Only the specified number of lines from the beginning of the file are read.
  • -Tail: Only the specified number of lines from the end of the file are read.

13. Test-Connection (ping, tnc)

The "Test-Connection" cmdlet lets you check network connectivity to a remote computer or server, which is similar to the "ping" command.

This command can send ICMP echo requests (pings) to a target computer to determine if the target computer is reachable on the network and measure round-trip time (RTT) for each ping.

Usage:

  • Test-Connection -ComputerName DESTINATION-NAME-OR-IP
  • Example 1: Test-Connection -ComputerName bing.com – Sends four pings to the destination and displays detailed results.
  • Example 2: Test-Connection -ComputerName 10.1.4.158 -Count 3 – Sends three pings to the IP address 10.1.4.158.
  • Example 3: Test-Connection -ComputerName bing.com -Quiet – Returns True or False depending on whether the connection to bing.com was successful.

(Image credit: Mauro Huculak)

Key Parameters:

  • -ComputerName: Specifies the target computer or IP address.
  • -Count: Specifies the number of pings to send.
  • -Interval: Specifies the time interval between pings.
  • -Quiet: Returns only a boolean value (True/False) indicating success or failure.
  • -TraceRoute: Displays the hops along the way, including the IP address and response time for each hop.

PowerShell doesn't include an equivalent for the "tracert" command. However, you can use the "Test-NetConnection" command with the "-TraceRoute" switch. For example, Test-NetConnection -ComputerName bing.com -TraceRoute

14. Get-NetIPConfiguration

The "Get-NetIPConfiguration" cmdlet provides a comprehensive overview of your computer's network adapter configurations.

This command can gather detailed information about all network adapters on your system, including interface name, MAC address, IP address, Subnet mask, Default Gateway, and DNS Servers.

Usage:

  • Get-NetIPConfiguration
  • Example 1: Get-NetIPConfiguration -Name "Ethernet0" – Shows the network configuration of the adapter. In this case, "Ethernet0," but you can specify the adapter you want.
  • Example 2: Get-NetIPConfiguration -InterfaceIndex 1 – Displays the network configuration for the adapter with the specified index. In this case, "1," but you can specify the adapter you want.
  • Example 3: Get-NetIPConfiguration | Select-Object InterfaceName, IPv4Address – Shows only the InterfaceName and IPv4Address properties for all network adapters.

(Image credit: Mauro Huculak)

15. Get-NetIPAddress

The "Get-NetIPAddress" cmdlet retrieves IP address information from network adapters on a local computer.

This command can gather information about IPv4 and IPv6 addresses associated with the network interfaces, including address state, interface index, prefix length, and valid lifetime.

Usage:

  • Get-NetIPAddress
  • Example 1: Get-NetIPAddress -AddressFamily IPv4 – Displays the IPv4 addresses.
  • Example 2: Get-NetIPAddress -InterfaceIndex 1 – This command displays the IP information for the adapter with an index of "1." You can change the number to show the information for a specific adapter.

(Image credit: Mauro Huculak)

Key Parameters:

  • -AddressFamily: Specifies the type of addresses you want to retrieve (e.g., IPv4, IPv6).
  • -InterfaceIndex: Filters results based on the network interface's index.
  • -AddressState: Filters results based on the address state (for example, Preferred, Obsoleted).

The "Get-NetIPAddress" command is similar to the "Get-NetIPConfiguration" command. However, the "Get-NetIPAddress" command focuses more specifically on the IP address configuration, while the "Get-NetIPConfiguration" command provides a comprehensive overview of network adapters and their configurations.

More resources

Find in-depth guides, troubleshooting tips, and the latest updates on Windows 11 and 10 here:

Mauro Huculak

Mauro Huculak has been a Windows How-To Expert contributor for WindowsCentral.com for nearly a decade and has over 15 years of experience writing comprehensive guides. He also has an IT background and has achieved different professional certifications from Microsoft, Cisco, VMware, and CompTIA. He has been recognized as a Microsoft MVP for many years.