Close Menu
Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Facebook X (Twitter) Instagram
Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Tech News Today
Home » Windows

How to Change Directory in Powershell

Bishwo TamliBy Bishwo TamliFebruary 26, 2023
powershell-change-directory

In Powershell, you can run automation scripts from specific folders or perform specific tasks in different file locations. However, it opens in the user account folder by default, and the Elevated version of it opens in the System32 folder.

So, to use the full extent of PowerShell, you will need to change directories and be able to navigate them. To do so, you can either use the built-in cmdlet made to navigate your current working directory (CWD) or its aliases like cd, sl, or chdir.

Table of Contents

  • Change Directory Using Absolute Path
  • Change Directory Using Relative Path
  • Change to Parent Folder in PowerShell
  • Set-location Aliases

Change Directory Using Absolute Path

You can easily change your current working directory in PowerShell by using the Set-location cmdlet. Its syntax is Set-location “absolute file path”.

The “absolute file path” refers to the full file location of the particular folder you’re trying to navigate towards. For instance, the Set-location “C:\Windows\Temp” will change your CWD to the Temp folder.

change directories in powershell

If you don’t know how to get the full file path of a particular folder, you can right-click that specific folder in File Explorer and select Copy as path. Then, you can simply put the Set-location cmdlet and paste your copied file path into Powershell.

copy as path in file explorer

Additionally, the double quotation marks enclosing the “absolute file path” isn’t mandatory. It is only necessary to enclose them within double quotation marks if your file path contains spaces. For example, Set-location “D:\Adobe Photoshop\config files”.

set location in powershell double quotation

Change Directory Using Relative Path

Changing the directory using relative file path also uses the same Set-location cmdlet, but you won’t need to enter the full file path of a folder. In a nutshell, it’s simply changing to a subfolder from a folder you’re already in.

For instance, your current working directory is C:\Windows and you want to get to the C:\Windows\Temp folder. In such cases, instead of using the above method, you can use the Set-location cmdlet with the relative file path. The command should look like this: Set-location Temp

changing directory in powershell with relative file path

Furthermore, you can keep adding more subfolders in the relative file path to navigate to the subfolder’s subfolder, and so on. For example, Set-location Temp\Crashpad\reports. (Make sure to add quotations if they contain spaces.)

changing to subfolders in powershell

Additionally, if you don’t remember the name of the subfolder you want to navigate to, you can use the dir cmdlet alias to view all the files and folders present in your CWD. 

dir command in powershell

Change to Parent Folder in PowerShell

Using the Set-location cmdlet, you can also go back to the parent folder of a directory you’re currently in. For example, if you’re in C:\Windows\Temp, and you want to navigate back to C:\Windows, you can use the Set-location .. command to directly go back to C:\Windows.

back directory in powershell

Also, if you want to jump back to the root folder of your current working directory, you can use the Set-location \ command. For example, if your CWD is C:\Windows\Temp\Crashpad\reports, this command will directly take you to C:.

go to the root folder in powershell

Set-location Aliases

You can also use Set-location aliases instead of the full Set-location cmdlet. A cmdlet alias is basically a shortened version of a cmdlet that performs the same function as the original cmdlet. The Set-location cmdlet has three aliases—cd, sl, and chdir.

You can use any of the three aliases instead of the actual cmdlet. The syntax for using the three aliases in any scenario is the same as Set-location.

set location cmdlet and its aliases

However, the cd alias does differ slightly compared to Set-location and its other aliases. When using the cd alias, you won’t need spaces when navigating back to the parent or root folder. For example, cd.. and cd\ will work perfectly fine, but Set location.. And Set-location\ won’t work.

cd and set location cmdlet difference

Lastly, you can also jump directly to a particular directory in PowerShell from File Explorer. All you need to do is to navigate to that folder in File Explorer and enter powershell in the address bar.

how-to
Bishwo Tamli

I'm a tech enthusiast, and I've always been troubleshooting errors by myself for years. I also like keeping up to date with the latest technology and gadgets.

Related Posts

scanning and repairing drive stuck

Windows Stuck in Scanning and Repairing Drive Screen? 4 Easy Fixes

December 4, 2023
Scanning and Repairing Drive

How to Fix Scanning and Repairing Drive on Every Boot?

November 24, 2023
how to download and use rufus

How to Download and Use Rufus

September 28, 2023
how to turn off hardware acceleration

How to Turn Off Hardware Acceleration

September 27, 2023
what happens if you turn off your computer during an update

What Happens if You Turn Off Your Computer During an Update?

September 18, 2023
How to Disable Integrated Graphics

How to Disable Integrated Graphics?

September 16, 2023
Add A Comment

Leave A Reply Cancel Reply

Latest Posts
scanning and repairing drive stuck

Windows Stuck in Scanning and Repairing Drive Screen? 4 Easy Fixes

December 4, 2023
computer died

Computer Died? Here’s What You Should Do Next

December 1, 2023
how-to-share-a-printer

How to Share a Printer on Network (Step-by-Step Guide)

November 28, 2023
You may also like
printer-not-printing

How to Fix a Printer That’s Not Printing

September 26, 2023
Share Location With Friends and Family

Share Location With Friends and Family (iPhone and Android)

September 18, 2023
how-to-print-without-a-printer

How to Print Without a Printer

September 18, 2023
Recommended
Cookie Clicker Garden Guide

Cookie Clicker Garden Guide to Unlocking Every Seed

September 26, 2021
monitor no signal

Computer Turns On But Monitor Says No Signal (9 Ways To Fix)

November 10, 2022
Facebook X (Twitter) Pinterest
  • Home
  • About Us
  • Our Team
  • Editorial Guidelines
  • Privacy Policy
  • Affiliate Disclosure
© 2023 TechNewsToday, editor@technewstoday.com | Tech Central Pvt. Ltd.

Type above and press Enter to search. Press Esc to cancel.