In Powershell, you may 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 utilize the full extent of PowerShell, you will need to change directories and be able to navigate them. To do so, you may either use the built-in cmdlet made to navigate your current working directory (CWD) or its aliases like cd, sl, or chdir.

Change Directory Using Absolute Path

you may easily change your current working directory in PowerShell by using theSet-locationcmdlet. Its syntax isSet-location “absolute file path”.

change-directories-in-powershell

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

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

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”.

copy-as-path-in-file-explorer

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 isC:\Windowsand you want to get to theC:\Windows\Temp folder. In such cases, instead of using the above method, you may utilize the Set-location cmdlet with the relative file path. The command should look like this:Set-location Temp

Furthermore, you may 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. (ensure to add quotations if they contain spaces.)

set-location-in-powershell-double-quotation

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

Change to Parent Folder in PowerShell

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

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

changing-directory-in-powershell-with-relative-file-path

changing-to-subfolders-in-powershell

dir-command-in-powershell

back-directory-in-powershell

go-to-the-root-folder-in-powershell