PowerShell profile

Also known as: $PROFILE

On this page 7

A PowerShell profile is an ordinary PowerShell script that runs automatically every time a new session starts, before the first prompt appears. In the PowerShell & command line toolset of Windows, it is the standard place to define aliases, functions, variables, module imports and prompt customizations that a user wants available in every console window without typing them again.

The automatic variable $PROFILE stores the path to the current user’s profile for the current host, which is why administrators often use “$PROFILE” as a synonym for the file itself. A profile is not a configuration file in a special format: it is plain PowerShell code, so anything that works at the prompt also works in the profile, including mistakes that slow down or break startup.

How a PowerShell profile loads at startup

When a host such as the console, Windows Terminal or the Visual Studio Code extension starts PowerShell, the engine checks up to four profile paths and dot-sources each file that exists. Dot-sourcing means the script runs in the global scope of the session, so the functions, aliases and variables it defines remain available after the script finishes.

The four profiles combine two dimensions: all users or the current user, and all hosts or the current host. They run in a fixed order from the most general to the most specific, so a later profile can override settings made by an earlier one. Each host has its own host-specific file name, such as Microsoft.PowerShell_profile.ps1 for the console and Microsoft.VSCode_profile.ps1 for the Visual Studio Code integrated console.

The following table lists the four profiles in load order with their typical locations in PowerShell 7 on Windows.

Profile propertyApplies toTypical path in PowerShell 7
AllUsersAllHostsEvery user, every host$PSHOME\Profile.ps1
AllUsersCurrentHostEvery user, one host$PSHOME\Microsoft.PowerShell_profile.ps1
CurrentUserAllHostsOne user, every host$HOME\Documents\PowerShell\Profile.ps1
CurrentUserCurrentHostOne user, one host$HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
The four profile scopes in load order

The $PROFILE variable itself points to CurrentUserCurrentHost, but it also carries the other three paths as note properties, so $PROFILE.AllUsersAllHosts returns the machine-wide path. The files do not exist by default; a user creates the personal one with New-Item -Path $PROFILE -ItemType File -Force after checking with Test-Path $PROFILE.

Windows PowerShell 5.1 and PowerShell 7 profile differences

Windows PowerShell 5.1 and PowerShell 7 keep separate profiles, because they are separate products with different installation folders and module paths. A function defined in one profile is therefore not visible in the other edition unless the user deliberately dot-sources a shared file from both.

The table below compares the most relevant differences that affect where a profile lives and whether it runs.

AspectWindows PowerShell 5.1PowerShell 7
Personal profile folderDocuments\WindowsPowerShellDocuments\PowerShell
Machine-wide folder$PSHOME under System32$PSHOME under Program Files
Executablepowershell.exepwsh.exe
Default execution policy on client WindowsRestrictedRemoteSigned
Startup time warningNot shownShown when profiles exceed about 500 ms
Profile behavior by PowerShell edition

A common practical issue is OneDrive folder redirection. When the Documents folder is moved into OneDrive, the personal profile path moves with it, which can cause synchronization conflicts or a missing profile on a new device until the files finish syncing.

What belongs in a PowerShell profile

A good profile contains small, fast and idempotent customizations that make interactive work more efficient. It should describe the working environment, not perform heavy tasks, because every new tab and window pays the startup cost.

  • Aliases and short functions for frequent commands, such as a function that jumps to a projects folder.
  • Prompt customization through a prompt function or a prompt module that shows the path, Git branch or elevation state.
  • PSReadLine options, for example predictive IntelliSense, history search and key handlers.
  • Default parameter values set through $PSDefaultParameterValues, such as a default encoding for export cmdlets.
  • Argument completers registered for command-line tools that support tab completion.

The next table works as a decision guide for choosing the right scope for a given customization.

CustomizationRecommended scopeReason
Personal aliases and promptCurrentUserCurrentHostAffects only one user in one host
Helper functions used in every editorCurrentUserAllHostsShared by the console and Visual Studio Code
Organization-wide proxy or module pathAllUsersAllHostsApplies to every account on the machine
Reusable tooling for a teamA PowerShell moduleVersioned, testable and loaded on demand
Choosing the profile scope for a setting

Profiles compared with modules, scripts and execution policy

A profile is one special script with an automatic trigger, while a PowerShell script runs only when called and a PowerShell module packages reusable commands that load on demand through module autoloading. Mature setups keep the profile short and move substantial logic into modules, often installed from the PowerShell Gallery.

Because a profile is a .ps1 file, the execution policy applies to it. Under the Restricted policy, PowerShell skips the profile and displays an error that scripts are disabled. Setting RemoteSigned for the current user is the usual fix, though organizations that enforce AllSigned require the profile itself to carry a valid Authenticode signature.

Profiles also do not run in every context. Starting PowerShell with -NoProfile skips all four files, which is the recommended practice for scheduled tasks and automation scripts, and remote sessions created through PowerShell remoting do not load local profiles by default. A script that silently depends on a profile function will therefore fail when run unattended.

Common PowerShell profile problems and fixes

Most profile problems come from slow startup, missing paths or hidden dependencies. The table below links frequent symptoms to their causes and practical remedies.

SymptomLikely causeFix
Error about running scripts being disabledRestricted execution policySet RemoteSigned for the current user
New tabs open slowlyEager module imports or network callsLazy-load modules and remove network checks
Customizations missing in Visual Studio CodeSettings placed in the console-only profileMove them to CurrentUserAllHosts
Function works interactively but not in a taskTask runs with -NoProfileDefine the function inside the script
Changes have no effectEdited the wrong edition’s fileCheck $PROFILE in the edition in use
Troubleshooting profile issues

To apply edits without opening a new window, a user can reload the profile with . $PROFILE. For performance analysis, measuring startup with Measure-Command around pwsh -Command exit shows how much time the profile adds, and commenting out sections isolates the slow part.

The idea in brief

A PowerShell profile is like a personal checklist that PowerShell reads every time it opens. Whatever is written in it is set up automatically. This can include shortcuts, favorite settings or a custom prompt. The user does not have to repeat them in every new window.

There can be several such checklists. One serves everyone on the computer, and another serves each person. Some apply only to a particular program. The key point is that a profile should stay short and quick. PowerShell reads it at every start, so a long list makes every new window slower.

A practical scenario

A systems administrator who manages about 200 Windows servers opens a dozen PowerShell tabs in Windows Terminal each day. Her CurrentUserAllHosts profile defines a function that connects to a chosen server group, sets PSReadLine predictive history, and configures a prompt that turns red when the session runs elevated, so she never confuses an administrator tab with a normal one.

After she added several module imports, new tabs began taking nearly three seconds to open. Measuring startup revealed that one inventory module accounted for most of the delay. She removed the explicit import and relied on module autoloading, which loads the module only when one of its commands is first used. Startup dropped to under half a second, and her scheduled maintenance scripts, which run with -NoProfile, continued to work because they never depended on the profile.