How to Change Directories in Windows PowerShell

Learn the change directory Windows PowerShell commands for switching folders, handling spaces, and setting where new sessions start.

Contents

Don't Miss the Good Stuff

Get tech news that matters delivered to your inbox.

To change directory in Windows PowerShell, type cd followed by the folder path, then press Enter. For example, cd 'C:\Windows' takes you to the Windows folder. Put quotation marks around paths containing spaces.

The directory commands below work in Windows PowerShell 5.1 and PowerShell 7.4, 7.5, and 7.6 unless a method specifies otherwise. Changing directories in built-in Windows PowerShell 5.1 requires no download.

The short version

  • Choose a folder: Enter cd followed by its path, then press Enter.
  • Handle spaces: Enclose the entire path in quotes, as in cd 'C:\Program Files'.
  • Move up: Use cd .. to reach the parent folder.
  • Check your location: Run Get-Location to see your current directory.

TaskCommand or controlWhat to remember
Open a specific foldercd 'C:\Windows'Quote paths containing spaces
Move to a nearby foldercd .\Subfolder or cd ..The path starts from your current folder
Switch drivescd D:\cd D: restores the drive's remembered location
Open a network shareSet-Location '\\FS01\Public'You need access to the share
Complete a pathTabCompletion depends on your host and configuration
Return homeSet-LocationLeave out the destination path
Move temporarilyPush-Location and Pop-LocationSave your location before moving
Handle literal bracketsSet-Location -LiteralPathCharacters are treated literally
Choose a folder with a wildcardSet-Location -Path 'C:\Win*'The pattern must match exactly one folder
Launch from Explorer's address barwt -p "Windows PowerShell" -d .Requires Windows Terminal
Launch from Explorer's context menuOpen in TerminalRequires Windows 11 integration and a default PowerShell profile
Choose a recurring Terminal folderStarting directoryA PowerShell startup script can override it
Start PowerShell 7 at a folderpwsh -WorkingDirectoryStarts another session
Start Windows PowerShell at a folderpowershell.exe -NoExit -CommandSupply a directory-changing startup command

Change to a folder using its full path

In PowerShell, enter the following command and press Enter. It changes your current directory to the Windows folder:

cd 'C:\Windows'

The command cd is an alias for Set-Location, so either name performs the same task. To use the full command name with an explicit path parameter, enter:

Set-Location -Path 'C:\Windows'

For a folder whose name contains spaces, surround the entire path with quotation marks. Keep both the drive letter and folder names inside the quotes:

cd 'C:\Program Files'

After moving, use Get-Location to check your current directory. Enter this command and press Enter:

Get-Location

Move into a subfolder or up a level

A relative path starts from your current folder. To enter a child folder, replace Subfolder with its name, then run:

cd .\Subfolder

Two dots represent the parent folder. To move up one level, enter this command and press Enter:

cd ..

You can also move up two levels in one command. Use the following when your destination is the parent of the parent folder:

cd ..\..

Switch drives or open a network folder

To change to another drive, include its letter in the destination path. For example, enter this command to move to the root of D:, provided that drive exists:

cd D:\

A full path can take you directly to a folder on that drive. If D: contains a folder named Projects, run:

cd D:\Projects

The trailing backslash matters when you want the drive root. Leave it out to restore the location PowerShell remembers for that drive:

cd D:

You can also move directly to a network share when you have access to it. Replace the server and share names below, then press Enter:

Set-Location '\\FS01\Public'

Complete folder paths with the keyboard

Path completion saves you from typing the entire destination. Start with this partial command, then press Tab to complete a matching path:

cd C:\Win

Press Tab again to cycle through matches, then press Enter when the intended folder appears. With PSReadLine, Ctrl + Space displays a completion menu. Completion keys depend on your host and PSReadLine configuration, so enter the complete path yourself if those keys do not complete it.

Return home or save your current location

To return to your home directory, run Set-Location without a destination. Enter the command below and press Enter:

Set-Location

For a temporary visit to another folder, use Push-Location to save your current location and move. This example remembers where you started before taking you to the Windows folder:

Push-Location 'C:\Windows'

When you are ready to return, run Pop-Location. It takes you back to the location you saved:

Pop-Location

Fix paths with brackets or multiple matches

Square brackets and other wildcard characters can be interpreted as patterns in a path. Use Set-Location with -LiteralPath when those characters are part of the actual folder name. Replace the example path below with your destination, keeping the quotes, then press Enter:

Set-Location -LiteralPath 'C:\Reports\[2026]'

If you intend to use a wildcard, supply it through -Path instead. The following pattern must identify exactly one folder; if multiple folders match, the command produces an error:

Set-Location -Path 'C:\Win*'

When a pattern matches more than one folder, replace it with the exact destination path. Use -LiteralPath if that exact name itself contains wildcard characters.

Open PowerShell at a File Explorer folder

With Windows Terminal installed, open your desired folder in File Explorer and select its address bar. Enter the following command, then press Enter to open Windows PowerShell at that folder:

wt -p "Windows PowerShell" -d .

The explicit -d . keeps Terminal's configured starting directory from replacing the File Explorer location. If PowerShell 7 is installed and available on PATH, you can alternatively enter this command in Explorer's address bar and press Enter:

pwsh

On Windows 11, with Windows Terminal's Explorer integration registered and a PowerShell profile configured as Terminal's default, right-click the folder background and select Open in Terminal. That opens a session at the folder. On Windows 10, context-menu availability problems can affect this method, so use the address-bar command with Windows Terminal.

Choose a starting folder for new sessions

For a recurring starting folder in Windows Terminal, find Starting directory in your PowerShell profile's settings and select Browse... to choose a folder. Save the setting, then open a new session using that profile. A PowerShell startup script can override this setting.

For a single new PowerShell 7 session, specify the folder when launching it. In PowerShell 7.4 through 7.6, run:

pwsh -WorkingDirectory 'C:\Windows'

Windows PowerShell 5.1 uses a startup command for this task instead of the -WorkingDirectory parameter. The following command opens a new session, changes its location, and keeps it open with -NoExit:

powershell.exe -NoExit -Command "Set-Location -LiteralPath 'C:\Windows'"

Frequently Asked Questions

What other command names can you use to change directories?

You can use chdir or sl as aliases for Set-Location in Windows PowerShell 5.1 and PowerShell 7.4 through 7.6. For example, chdir 'C:\Windows' and sl 'C:\Windows' take you to the same folder as cd 'C:\Windows'.

Can you revisit the previous directory without saving it first?

In PowerShell 7.4 through 7.6, run cd - to revisit the previous location or cd + to move forward. PowerShell retains up to 20 locations independently of the location stack. These history commands are unavailable in Windows PowerShell 5.1, where you can save your starting location with Push-Location before moving and return with Pop-Location.

Can you supply a directory path through a pipeline?

Yes, run 'C:\Windows' | Set-Location in Windows PowerShell 5.1 or PowerShell 7.4 through 7.6. Pipeline strings bind to Path, not LiteralPath. If your folder name contains literal wildcard characters, supply the path directly with -LiteralPath.

Can you keep a separate stack of saved locations?

Yes, use a named stack in Windows PowerShell 5.1 or PowerShell 7.4 through 7.6. Run Push-Location 'C:\Windows' -StackName Work to save your current location to that stack and move, then run Pop-Location -StackName Work to return. You can also use pushd as an alias for Push-Location.

Share