How to Change a Directory in PowerShell

Navigating your file system is one of the most fundamental tasks in any command-line environment. In PowerShell, changing directories is straightforward once you understand the commands available and how they behave — but there are a few nuances that catch people off guard, especially if you're coming from Command Prompt or a Unix-based terminal.

The Core Command: Set-Location

PowerShell's native command for changing directories is Set-Location. It tells PowerShell to move your active working location to a different path on your file system.

Set-Location C:UsersYourNameDocuments 

After running this, any subsequent commands that reference relative paths will operate from that new location.

PowerShell also accepts two aliases for Set-Location that most users find more convenient:

  • cd — borrowed from Command Prompt and Unix shells
  • sl — a shorter PowerShell-specific alias

All three do exactly the same thing. cd is by far the most commonly used in practice.

cd C:UsersYourNameDocuments 

Navigating with Relative vs. Absolute Paths

Understanding the difference between absolute and relative paths changes how efficiently you can move around.

Absolute paths start from the root of a drive and specify the full location:

cd C:Program FilesMyApp 

Relative paths navigate from wherever you currently are:

cd Documents 

Two special relative path shortcuts work in PowerShell just as they do in other shells:

ShortcutWhat It Does
.Refers to the current directory
..Moves up one level to the parent directory
~Refers to your home/user profile directory

So if you're in C:UsersYourNameDocuments and want to go up one level:

cd .. 

That puts you in C:UsersYourName. You can chain these together too:

cd .... 

This moves up two levels in a single command.

Using the Tilde Shortcut for Your Home Directory 🏠

PowerShell recognizes ~ as a shortcut to your user home directory — typically C:UsersYourName on Windows. This is useful when you want to jump back to a familiar starting point without typing a full path:

cd ~ 

Or navigate directly to a subfolder within your home directory:

cd ~Desktop 

Handling Paths with Spaces

A common stumbling block: directory names with spaces. If you try to navigate to a path like C:Program Files without quoting it, PowerShell will misread everything after the space as a separate argument.

The fix is to wrap the path in single or double quotes:

cd "C:Program Files" 

or

cd 'C:Program Files' 

Both work. Double quotes allow variable expansion inside the path; single quotes treat the string as literal text. For most directory navigation, either is fine.

Switching Between Drives

Changing directories across different drives — for example, from C: to D: — works slightly differently than it does in the old Command Prompt.

In PowerShell, Set-Location handles drive changes cleanly in a single command:

cd D:Projects 

This moves you to D:Projects in one step. You don't need to type D: separately first, which was the old CMD approach.

Navigating PowerShell Providers Beyond the File System

One thing that makes PowerShell unique is that Set-Location isn't limited to your file system. PowerShell uses a concept called providers, which means you can navigate other data stores using the same cd command — including:

  • The registry:cd HKLM:Software
  • Environment variables:cd Env:
  • Certificate stores:cd Cert:

This is a meaningful distinction from Command Prompt. The cd command in PowerShell is operating against any provider, not just disk drives. For most everyday use, you'll be working with the file system, but it's worth knowing that the command is more versatile than it looks.

Tab Completion Makes Navigation Faster ⚡

PowerShell supports tab completion for paths, which dramatically speeds up directory navigation. Start typing a path and press Tab to auto-complete folder names. Press Tab repeatedly to cycle through matching options.

cd C:Us[Tab] → C:Users 

This also catches spelling errors before they become failed commands — a small but genuinely useful feature when working in deeply nested directory structures.

Returning to a Previous Location

PowerShell includes Push-Location (pushd) and Pop-Location (popd) for cases where you need to temporarily move to another directory and then return:

Push-Location C:Temp # Do work here Pop-Location # Now you're back where you started 

This is particularly useful in scripts where you need to change directories mid-execution without losing track of where you started.

What Affects Your Navigation Experience

How you end up using these commands in practice depends on several factors:

  • Your PowerShell version — PowerShell 5.1 (built into Windows) and PowerShell 7+ (cross-platform) both support all the commands above, but PowerShell 7 adds improved tab completion and cross-platform path handling
  • Your shell profile configuration — custom profiles can add functions or aliases that change default navigation behavior
  • Whether you're scripting or working interactively — absolute paths are generally safer in scripts; relative paths are faster for interactive use
  • Operating system — on macOS or Linux running PowerShell 7, paths use forward slashes (/) rather than backslashes, though PowerShell often handles both
  • Your file system depth and naming conventions — heavily nested structures or paths with special characters add friction that tab completion and quoting rules directly affect

The commands themselves are consistent. How well they serve your workflow depends on the environment you're working in and what you're actually trying to accomplish. 🖥️