How to Create and Customise a PowerShell Profile in Windows 11

Every time you launch a new terminal session in Windows 11, PowerShell initializes with default environment variables, standard path configurations, and basic console prompts. Repeating identical setup commands—such as importing administrative modules, defining custom navigation functions, setting proxy parameters, or creating short aliases—introduces daily friction into development workflows. A PowerShell Profile is a startup script that runs automatically whenever PowerShell starts. Understanding how to create, customize, and secure PowerShell profiles enables developers and systems engineers to tailor their command-line environment for maximum productivity.

Understanding PowerShell Profile Types and Scopes

PowerShell supports six distinct profile script locations depending on whether you are running Windows PowerShell (5.1) or PowerShell 7 (Core), and whether configurations should apply to the current user or all machine accounts:

  • Current User, Current Host ($PROFILE): The most common profile. Applies exclusively to the logged-in user within the specific terminal application (e.g., Windows Terminal / console). Stored in $HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1.
  • Current User, All Hosts: Applies to the user across all PowerShell hosts (including VS Code integrated terminals). Stored in $HOME\Documents\PowerShell\profile.ps1.
  • All Users, Current Host: Applies machine-wide to all accounts launching that specific PowerShell host. Stored in $PSHOME\Microsoft.PowerShell_profile.ps1 (requires Administrator rights).
  • All Users, All Hosts: Applies to all users across every hosting environment. Stored in $PSHOME\profile.ps1.

Prerequisites and Environment Setup

  • Windows 11 with Windows Terminal and PowerShell 5.1 or PowerShell 7+ installed.
  • PowerShell execution policy configured to permit running local scripts (e.g., RemoteSigned).
# Check and set script execution policy if needed
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Verifying and Creating Your PowerShell Profile

By default, Windows does not pre-create profile script files. You can verify whether a profile exists and create it using the automatic $PROFILE variable:

# Check if profile script exists
Test-Path -Path $PROFILE

# If False, create the profile script and its parent directory automatically
if (-not (Test-Path -Path $PROFILE)) {
    New-Item -ItemType File -Path $PROFILE -Force
    Write-Host "PowerShell profile created at: $PROFILE" -ForegroundColor Green
}

Editing the Profile in Notepad or VS Code

To open the profile script for editing directly from your terminal session:

# Open in Windows Notepad
notepad $PROFILE

# Alternatively, open in Visual Studio Code
code $PROFILE

Essential Customisations to Add to Your Profile

Paste the following productivity enhancements into your profile script:

1. Custom Navigation Functions and Aliases

# Quick directory navigation
function .. { Set-Location .. }
function ... { Set-Location ..\.. }
function gocode { Set-Location "$HOME\Projects" }

# Useful command aliases
Set-Alias -Name ll -Value Get-ChildItem
Set-Alias -Name grep -Value Select-String

2. Customizing the Terminal Prompt and Git Status

You can customize the prompt function to display execution timestamps or current Git branches:

function prompt {
    $time = Get-Date -Format "HH:mm:ss"
    $currentPath = (Get-Location).Path.Replace($HOME, "~")
    
    # Write custom prompt with color formatting
    Write-Host "[$time] " -NoNewline -ForegroundColor DarkGray
    Write-Host "$currentPath" -NoNewline -ForegroundColor Cyan
    return "`n> "
}

3. Enabling Predictive IntelliSense and Autocomplete

If utilizing the PSReadLine module (bundled with modern PowerShell), configure inline predictive text:

# Enable history-based predictive IntelliSense
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -Colors @{
    InlinePrediction = "$([char]0x1b)[38;5;238m"
}

Reloading Profile Changes Without Restarting Terminal

After saving edits to your profile script, reload configurations into your active terminal window by dot-sourcing the file:

. $PROFILE

Testing and Troubleshooting Profile Load Performance

Heavy profile scripts containing network queries or slow module imports can delay terminal startup times. You can measure your profile execution time:

Measure-Command { . $PROFILE }

If startup exceeds 300–500 milliseconds, avoid importing bulky modules synchronously; instead, use PowerShell autoloading or defer module imports until needed.

Best Practice Security Tips

  • Protect Profile Permissions: Ensure your profile directory (Documents\PowerShell) is writable only by your personal user account to prevent unauthorized script injection.
  • Bypass Profile When Troubleshooting: If a corrupted profile crashes your console, launch PowerShell without loading profiles using: pwsh -NoProfile or powershell -NoProfile.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.