How to Change Directory in PowerShell (Complete Guide)
Navigating your file system is one of the most fundamental skills in PowerShell. Whether you're running scripts, managing files, or automating tasks, knowing how to move between directories quickly and confidently makes everything else easier.
The Core Command: Set-Location
PowerShell's native command for changing directories is Set-Location. It tells PowerShell where to look when you run commands, access files, or execute scripts.
Set-Location C:UsersYourNameDocuments After running this, your prompt updates to reflect the new working directory, and any relative file paths you use will resolve from that location.
PowerShell also supports two shorter alternatives that do exactly the same thing:
cd— borrowed from both Command Prompt and Unix shellschdir— another legacy alias carried over from older Windows shellssl— the official PowerShell alias forSet-Location
All four are interchangeable in practice. Most users default to cd out of habit.
cd C:UsersYourNameDocuments Navigating with Relative vs. Absolute Paths
Understanding path types changes how efficiently you move around.
Absolute paths start from the root of a drive and work regardless of where you currently are:
cd C:Program FilesWindowsPowerShell Relative paths navigate based on your current location. Two special symbols make this work:
.— represents the current directory..— represents the parent directory (one level up)
cd .. # Move up one level cd .... # Move up two levels cd .Scripts # Move into a subfolder called Scripts Relative paths are faster when you're already deep in a directory tree and just need to move one or two levels.
Changing Drives in PowerShell 🖥️
This trips up many users coming from Command Prompt. In PowerShell, simply typing D: won't always behave as expected inside all contexts. The reliable method is:
Set-Location D: Or just:
cd D: PowerShell also treats the registry, certificate stores, and other system structures as drives — meaning Set-Location works beyond the traditional file system:
cd HKLM:Software # Navigate into the Windows Registry cd Cert:LocalMachine # Navigate into the certificate store This is one area where PowerShell genuinely goes beyond what cmd.exe can do.
Handling Paths with Spaces
Paths containing spaces must be wrapped in quotes, or PowerShell will read each word as a separate argument:
cd "C:Program FilesCommon Files" Single quotes work too, but double quotes are generally preferred when the path might contain variables you want PowerShell to expand:
$folder = "MyProject" cd "C:UsersYourName$folder" # Double quotes allow variable expansion cd 'C:UsersYourName$folder' # Single quotes treat $ as a literal character Using Push-Location and Pop-Location for Smarter Navigation
When you need to jump to a directory temporarily and return to where you were, Set-Location alone requires you to remember the original path. Push-Location and Pop-Location solve this cleanly.
Push-Location C:TempWorkFiles # Save current location, then move # Do your work... Pop-Location # Return to the previously saved location Think of it like a bookmark stack — you can push multiple locations and pop them in reverse order. This is especially useful inside scripts where you need to change directories mid-process without losing your place.
Checking Your Current Location
Before navigating, it often helps to confirm where you are:
Get-Location # Returns the full path of your current directory pwd # Alias — stands for "print working directory" Both display the same information. pwd is a habit many users carry from Linux or macOS terminals.
Tab Completion and Path Wildcards ⚡
PowerShell's tab completion works with cd and Set-Location. Start typing a path and press Tab to cycle through matching directories — this saves time and avoids typos in long paths.
Wildcards aren't used for navigation itself (you can't cd into multiple directories at once), but they're useful in scripts that first find a path with Get-Item or Resolve-Path before navigating to it.
Variables in the Filesystem
| Symbol/Command | What It Represents |
|---|---|
~ | Current user's home directory |
. | Current directory |
.. | Parent directory |
$HOME | Environment variable for home folder |
$PSScriptRoot | Directory where the running script is located |
Using cd ~ drops you straight into your user profile folder, just like on Linux or macOS. $PSScriptRoot is particularly valuable in scripts that need to reference files stored alongside them.
cd ~ # Go to home directory cd $PSScriptRoot # Go to the script's own directory Variables That Affect the Experience
How you navigate directories in PowerShell can differ depending on a few key factors:
- PowerShell version — PowerShell 5.1 (built into Windows) behaves slightly differently from PowerShell 7+, particularly around cross-platform path handling
- Running environment — the integrated terminal in VS Code, Windows Terminal, or the classic PowerShell ISE each handle tab completion and display differently
- User permissions — attempting to navigate into a protected directory (like
C:WindowsSystem32in a restricted session) may require an elevated shell - Operating system — PowerShell on macOS and Linux uses forward-slash paths (
/home/user/documents) rather than backslashes, and drive letters don't apply
The commands themselves stay consistent, but path formatting and what's accessible varies based on your environment and permission level. What works smoothly in an admin session on Windows might behave differently in a non-elevated terminal or on a different OS entirely — which is worth keeping in mind as you build out your own workflows.