October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Find Special Folder Paths in PowerShell

Use .NET special-folder lookups for Windows paths, inspect $Env:PSModulePath for modules, and use $PROFILE properties for PowerShell profile scripts.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use [Environment]::GetFolderPath() to retrieve a Windows special-folder path at runtime instead of building one from a drive letter or user name. For PowerShell-specific locations, use $Env:PSModulePath to inspect module search directories and the properties of $PROFILE to locate profile scripts.

Get a Windows special-folder path

Pass a member of Environment.SpecialFolder to the .NET Environment.GetFolderPath method. The enum form is explicit; the string form is also accepted.

[Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments)
[Environment]::GetFolderPath('MyDocuments')

For example, the first command returns the current user’s Documents location as Windows resolves it. Microsoft notes that the location can vary with Windows version, folder redirection, and OneDrive, so avoid assuming it is always C:UsersnameDocuments. See Microsoft’s Environment.SpecialFolder reference and Environment.GetFolderPath reference.

The argument must identify a supported special folder. An invalid value raises ArgumentException; an unsupported platform can raise PlatformNotSupportedException.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
PowerShell for Sysadmins: Workflow Automation Made Easy
  • Book - powershell for sysadmins: workflow automation made easy
  • Language: english
  • Binding: paperback

Common folder identifiers

Identifier Use
MyDocuments (also known as Personal) The current user’s Documents folder; it may be redirected or moved.
ApplicationData Per-user application data intended to roam with the user.
LocalApplicationData Per-user application data that is local rather than roaming.
CommonApplicationData Application data shared among users; on Windows this commonly maps to C:ProgramData.
UserProfile The user’s profile root. Microsoft advises applications to place data under ApplicationData rather than creating files directly at the profile root.
Windows and System The Windows directory and system directory.
ProgramFiles and ProgramFilesX86 Architecture-specific program-file roots.

Choose the folder by purpose: roaming user settings belong under ApplicationData, machine-local user data under LocalApplicationData, and shared application data under CommonApplicationData. A known-folder lookup is a runtime result, not a promise that every machine uses the same literal path.

Find PowerShell module directories

Inspect $Env:PSModulePath to see the directories PowerShell searches for module manifests (.psd1) and module files (.psm1). On Windows, the value is a semicolon-separated list. Use the environment variable rather than constructing a module directory from assumptions:

$Env:PSModulePath -split ';'

Default locations differ between Windows PowerShell 5.1 and PowerShell 7. The following are the documented defaults; the actual search path can vary with configuration.

Scope PowerShell 7 Windows PowerShell 5.1
Current user $HOMEDocumentsPowerShellModules $HOMEDocumentsWindowsPowerShellModules
All users $Env:ProgramFilesPowerShellModules $Env:ProgramFilesWindowsPowerShellModules
Bundled with the installation $PSHOMEModules $PSHOMEModules

The user module path uses Documents, which can be redirected or backed by OneDrive. To check the resolved location, run [Environment]::GetFolderPath('MyDocuments'). Microsoft documents the search-path behavior and version-specific defaults in about_PSModulePath.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Get the correct PowerShell profile path

$PROFILE identifies profile script locations for the current PowerShell installation and host. Its four properties distinguish current-user from all-user profiles and the current host from all hosts:

$PROFILE.CurrentUserCurrentHost
$PROFILE.CurrentUserAllHosts
$PROFILE.AllUsersCurrentHost
$PROFILE.AllUsersAllHosts

Use the property that matches who should receive the settings and whether they should apply only to this host or every host. Current-user profiles are under the user’s home path; all-user profiles are under the PowerShell installation path. The resolved paths vary by host, operating system, and PowerShell version, so use these properties rather than assembling a profile path manually. See Microsoft’s PowerShell profiles documentation.

Make path lookups portable

  • Resolve known folders when the script runs; do not assume a system drive, user name, or localized folder name.
  • Choose a data scope deliberately: roaming, local per-user, or shared among users.
  • Use $Env:PSModulePath for module discovery and $PROFILE properties for profile scripts.
  • Treat familiar paths as common mappings, not guarantees. Windows documents %windir% for the Windows folder, %LOCALAPPDATA%Programs for per-user Programs, and C:ProgramData as a typical common-application-data location.
  • Account for Windows PowerShell 5.1 versus PowerShell 7 and for redirected or OneDrive-backed Documents folders.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.