Skip to content

PowerShell Environment: Setup, Installation, and Customization

How to install PowerShell, configure your environment across Windows, Linux, and macOS, and customize profiles for aliases, functions, and startup scripts.

Setting up a proper PowerShell environment involves choosing the right version to install, picking an editor, and understanding how startup customization works through profile files.

Installing PowerShell

PowerShell comes in two distinct editions: the legacy built-in Windows PowerShell and modern, cross-platform PowerShell 7+.

Windows PowerShell (Built-in)

Every modern version of Windows ships with Windows PowerShell pre-installed. You can launch it in several ways:

  • Type powershell into the Start menu search bar (easiest way).
  • Run powershell.exe directly from C:\Windows\System32\WindowsPowerShell\v1.0\.
  • Open it from Windows Terminal via the dropdown menu.

This built-in version is Windows PowerShell 5.1: it's stable but no longer receives new features.

For active development and cross-platform support, install PowerShell 7, distributed separately from Windows.

Consolepowershell
winget install --id Microsoft.PowerShell --source winget

where:

  • winget is the Windows Package Manager, pre-installed on modern Windows 10/11.
  • --id Microsoft.PowerShell specifies the exact package to install.

Alternatively, download the installer .msi package directly from the official PowerShell GitHub releases page.

Once installed, PowerShell 7 runs via the pwsh executable, separate from the legacy powershell.exe.

Installing on Linux and macOS

PowerShell 7 is fully supported on Linux and macOS since it's built on the cross-platform .NET runtime.

macOS

Consolepowershell
brew install --cask powershell

Linux (Ubuntu/Debian example)

Consolepowershell
sudo apt update
sudo apt install -y powershell

where:

  • apt is the Debian/Ubuntu package manager.
  • Package names and installation steps vary slightly by distribution, so refer to the official Microsoft docs for your specific distro.

Once installed, launch PowerShell on any platform with:

Consolepowershell
pwsh

Choosing an Editor

Several tools can be used to write and run PowerShell scripts, ranging from basic to fully featured.

Tool Description Best For
PowerShell ISE Windows-only, built-in graphical editor bundled with Windows PowerShell 5.1 Legacy scripting, simple edits (no longer actively developed)
Windows Terminal Modern, tabbed terminal application supporting pwsh, cmd, and WSL Running scripts, interactive sessions
Visual Studio Code Free, cross-platform code editor with the official PowerShell extension Writing, debugging, and maintaining scripts (recommended)

Checking Your Version

Once PowerShell is installed, verify the version and environment details using the $PSVersionTable automatic variable.

Consolepowershell
$PSVersionTable
Outputplaintext
Name                           Value
----                           -----
PSVersion                      7.6.6
PSEdition                      Core
GitCommitId                    7.6.6
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

where:

  • PSVersion shows the installed PowerShell version.
  • PSEdition indicates whether it's Core (PowerShell 6+) or Desktop (Windows PowerShell 5.1 and earlier).
  • OS and Platform display the underlying operating system details.

Profile Files ($PROFILE)

A profile is a script that runs automatically every time a PowerShell session starts, similar in purpose to .bashrc in Bash. It's used to customize your environment: defining aliases, functions, variables, or setting preferences.

The path to the current user's profile is stored in the $PROFILE automatic variable.

Consolepowershell
$PROFILE
Outputplaintext
C:\Users\Tom\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

If the file doesn't exist yet, create it:

Consolepowershell
if (!(Test-Path -Path $PROFILE)) {
    New-Item -ItemType File -Path $PROFILE -Force
}

where:

  • Test-Path checks whether the profile file already exists.
  • New-Item -ItemType File creates the file (and any missing parent folders, due to -Force) if it doesn't.

Open the profile in your editor and add customizations, such as a custom alias or a startup message:

Microsoft.PowerShell_profile.ps1powershell
Set-Alias ll Get-ChildItem
Write-Host "Welcome back, Tom! Today is $(Get-Date -Format 'dddd, MMMM dd')."

Next time you open PowerShell, your customizations load automatically:

Outputplaintext
Welcome back, Tom! Today is Sunday, September 27.

Next Steps

Continue to PowerShell Frequently Used Cmdlets to learn the most essential cmdlets every PowerShell user should know, including Get-Help, Get-Command, and Get-Member.

Navigation