PowerShell is one of the most powerful tools in Windows 11. It replaces the Windows Command Prompt to run tasks from the command line. However, it's way more powerful than a simple CLI replacement, adding functionality, flexibility, and scripting for peak productivity.

If you're a sysadmin, you might already use PowerShell daily, as it helps automate various tasks. Using the cmdlets built into PowerShell, you can perform remote admin tasks on systems, test network connections on servers, and perform many other vital functions. These can be combined into scripts, so a single command could handle a full installation of Windows, for example. This guide will give you enough background to start scripting, and also reveal the various tasks PowerShell could help you accomplish.

What is PowerShell?

A powerful CLI and scripting language

PowerShell is a powerful and versatile command-line interface and scripting language developed by Microsoft. Originally made just for administrating Windows, it's now open-source, so it can also work on macOS and Linux. The power comes from being able to script complex automated tasks and system configurations using code so that the tasks can be efficiently run in the same way every time. While it can be used for single tasks on your PC, it can also be used to set up new computers from scratch, including setting up user accounts and system variables, something that is difficult to do with any other scripting language.

What is the difference between classic Windows PowerShell and PowerShell?

Windows PowerShell is the older version of the program, which will never be updated past version 5.1. It's installed by default on Windows 11 and replaces the Command Prompt. It also only runs on Windows. On the other hand, PowerShell is now at version 7.4, and is open-source, cross-platform, and has been rewritten to use the .NET Core framework. It runs on Windows, macOS, and Linux, but requires a separate installation.

👁 Screenshot showing how to run a command in PowerShell Run.
What is Windows PowerShell, and why would you use it?

The average Windows user probably doesn't need to use PowerShell, but it's nice to know what it is if you do need it.

What is PowerShell ISE?

PowerShell Integrated Scripting Environment (ISE) is a GUI host application for PowerShell that enables useful functionality over the CLI. First, it can test and debug scripts, so that you know what your script will do before running it in a production environment. That makes it the best option for running PowerShell scripts, so you can see the script's contents before you run it on your machine. It can give you extra peace of mind by running it first in testing mode. It also has usability features from modern code editors, like multiline editing, tab completion, context-sensitive help, and selective execution, where you can run a selected portion of a script to test instead of running the entire thing.

How to install PowerShell

The version preinstalled in Windows 11 isn't the latest one

While Windows PowerShell is included in every version of Windows 11, you should install the newer, open-source version for two reasons. First, it's newer and actively developed, so you'll have access to the latest features. It's also cross-platform, so you can write scripts that will work on Windows, macOS, and Linux. You can use any of the methods below to obtain it.

To install PowerShell on Windows:

  • Download the latest release from the GitHub page.
  • Install the latest version from the Microsoft Store.
  • Type the following command in Windows Terminal:
    winget install Microsoft.PowerShell

To install PowerShell on macOS:

  • To install using Homebrew, start by installing Homebrew, then type the following into a Terminal window:
    brew install powershell/tap/powershell
  • Use a Direct Download: Download the package and double-click the file to start the installation process.
  • Advanced users could install the binary archives but need to manually install any dependencies.

To install PowerShell on Linux:

What is a PowerShell cmdlet?

Cmdlets are the basic building blocks of PowerShell. They follow a Verb-Noun naming structure, showing the action the cmdlet performs and the object of that action.

Cmdlet("verbName", "nounName")

It could also include optional parameters to limit the scope of the cmdlet.

Cmdlet("verbName", "nounName", Named Parameters...)

While PowerShell has over 200 built-in cmdlets, you can also make commands and functions using the approved naming schemes for nouns and verbs. The most common verbs are below in this table:

Verb

Action

Example

Add

Adds or appends are resources to another item

Add-MailboxPermission

Clear

Removes all resources from a container but doesn’t delete the container

Clear-Host

Connect

Makes a connection to another system

Connect-AzureAD

Disconnect

Break the connection with the other system

Disconnect-AzureAD

Get

Retrieves data from a resource

Get-ChildItem

New

Creates a new resource

New-Mailbox

Remove

Remove a resource from a container

Remove-Mailbox

Set

Replaces data in an existing resource

Set-Mailbox

Select

Selects a resource in a container

Select-Object

The good news is you don't need to master all of those cmdlets to become even advanced or an expert at PowerShell. All you need to do is get familiar with the following three cmdlets.

Get-Command

The Get-Command cmdlet is a handy way to find every cmdlet associated with the task you need to accomplish. Running it without any parameters gives you a long list like the one in the image above, with every command installed on your system. That's not very helpful, making finding the task you need harder. You can make things more specific by running Get-Command with additional parameters, which will help you narrow down which cmdlet to use.

For this example, we're using the noun Process, using the following command string:

Get-Command -Noun Process

Which will return the following table to your PowerShell window:

CommandType

Name

Version

Source

Cmdlet

Debug-Process

7.0.0.0

Microsoft.PowerShell.Management

Cmdlet

Get-Process

7.0.0.0

Microsoft.PowerShell.Management

Cmdlet

Start-Process

7.0.0.0

Microsoft.PowerShell.Management

Cmdlet

Stop-Process

7.0.0.0

Microsoft.PowerShell.Management

Cmdlet

Wait-Process

7.0.0.0

Microsoft.PowerShell.Management

The same command structure can also use wildcards, so using -Name *service* as a parameter will return every command that has service in part of the name. To limit this to native PowerShell commands, we need to add the CommandType parameter as below:

Get-Command -Name *service* -CommandType Cmdlet, Function, Alias

That limits the returned list to only cmdlets, functions, and aliases that PowerShell can use.

Get-Help

Once you've figured out which cmdlet you need, it's time to figure out how to use it. That's handled using the Get-Help cmdlet, which will show you the usage syntax, examples, and more for the cmdlet you want. Use the following command, with "name-of-cmdlet" substituted with the cmdlet you want help on.

Get-Help name-of-cmdlet

If you can't see the full help content, run the following command to update and download the necessary files and rerun your Get-Help command.

Update-Help

While the Get-Help cmdlet is functional, you won't see the entire help file without adding another parameter. That's -Full, which will add result sections for Parameters, Input, Output, Notes, and Examples, making it far more helpful while you are learning your way around.

Get-Help Get-Process -Full

Get-Member

The last cmdlet in the trio to know is Get-Member. This cmdlet shows the objects, properties, and methods available for a given command. Once you know this, you have all the building blocks necessary for creating scripts.

PowerShell is an object-orientated scripting and CLI tool. Objects are collections of data representing specific items. All objects have the same three types of data:

Object type: Kind of object it is

Object property: Information about the object

Object methods: Types of actions you can perform​​​​

It's worth knowing that Get-Member can't be used on its own. Instead, it needs another cmdlet piping down to it so that you get the list of properties and methods you are after. That's accomplished using the pipe operator "|" between the two cmdlets.

Get-Process | Get-Member
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 

This gives you every property and method associated with that object, but you may not need to see all those results. To narrow things down, add parameters like MemberType and Name (which specify the name of one or more properties or methods), like in this example:

Get-Process | Get-Member -MemberType Property

That will only return the property elements related to Get-Process while excluding any method elements.

Some useful PowerShell commands

PowerShell can show all kinds of interesting and important information that is often difficult to find using Windows's graphical interfaces. We've broken down a few to get you started.

Information collection

​​​​​​​List Windows operating system version:

Get-CimInstance -ClassName Win32_OperatingSystem |
Select-Object -Property BuildNumber,BuildType,OSType,ServicePackMajorVersion,ServicePackMinorVersion​​​​​​​

List number of local users and owner information:

Get-CimInstance -ClassName Win32_OperatingSystem |
Select-Object -Property NumberOfLicensedUsers,NumberOfUsers,RegisteredUser​​​​​​​

Working with files and folders

List all files and folders in a folder:

Get-ChildItem -Path C:\ -Force​​​​​​​

Copying files and folders:

Copy-Item -Path (path) -Destination (destination) - Force​​​​​​​

Creating new folders:

New-Item -Path '(path)' -ItemType Directory​​​​​​​

Creating new empty files:

New-Item -Path '(path)\(FileName.format)' -ItemType File​​​​​​​

There's a lot to PowerShell

PowerShell allows IT admins to handle almost any administrative task in a Windows environment without needing third-party tools. Whether used for deployment, monitoring, or automation, PowerShell scripts can handle many tasks once you get the hang of them. It's not that hard to learn, and there is a wide variety of online resources from which to learn more advanced tasks, like Microsoft's own developer blogs, personal blogs, and third-party course providers. If you want to supercharge your experience on a single PC, Microsoft PowerToys can be very useful to help you adjust things to your liking.