How to change directory in PowerShell? A lot of users are confused about the PowerShell change directory command. Don’t worry. This post of MiniTool will walk you through detailed steps to change directory PowerShell on Windows 10/11.
As it’s well known to us all, PowerShell is a practical Windows built-in command-line shell and scripting tool. It allows users to do various works by running specific cmdlets such as PowerShell get user group membership, PowerShell get disk space, PowerShell run exe, PowerShell copy files, PowerShell gets folder size, installing SSH PowerShell, PowerShell unzip/zip files, and more.
However, a great many people are unclear about how to deal with these works in PowerShell. For example, some users from the Stack Overflow community want to change directory in PowerShell but don’t know how to do that. So, here provide a full guide to explain the PowerShell change directory operation.
Change directory in PowerShell. My PowerShell prompts currently pointed to my C drive (PS C:\>). How do I change directory to a folder on my Q (PS Q:\>) drive? The folder name on my Q drive is "My Test Folder".
What Cmdlet Can Be Use to Change Directory in PowerShell
Before you do, it’s necessary to figure out the PowerShell change directory cmdlet first. What command can be used to change directory in PowerShell? After investigating extensive user reports and references, we find that the Get-Location cmdlet is the main way to determine and change the path of your current directory location in PowerShell.
In addition, some other commands can make Windows PowerShell change directory, including the cd, chdir, and sl commands. You can further read the following parts to know more details.
How to rename file CMD on Windows 10/11? Now, you come to the right place. This post will explain the CMD rename file operation in detail.
How to Change Directory in PowerShell Windows 10/11
Now, you should have known the PowerShell change working directory commands. Here’s how to change directory PowerShell in Windows 10/11 using these commands.
To show you how to make PowerShell change working directory more intuitively, all the following commands are operated assuming that you want to change directory to a folder on the D drive and the folder name on the drive is “Ariel”. Here you can replace the directory with your desired path.
# 1. Windows PowerShell Change Directory Via Set-Location
The first and most common way is to use the Set-Location command. The complete syntax of the command is “Set-Location -Path ... -PassThru”. The Path represents the relative or absolute path of the current directory and the PassThru alias enables you to apply the command even if the output is empty. Here’s how to make PowerShell change drive letter using the cmdlet.
Step 1. Press the Win + R keys to open the Run box, and then type powershell in it and hit Enter to open the Windows PowerShell screen.
Step 2. Now, you will find that PowerShell is usually pointing to C:\Users\Administory. To change the current directory to D:\Ariel in PowerShell, you can input the following command and hit Enter. Then the output should show you the current working directory of the PowerShell has been changed.
Set-Location -Path D:\Ariel -Passthru
# 2. Windows PowerShell Change Directory Via the CD Alias
The cd command serves the same function as the Set-Location cmdlet. It is very simple to operate via the syntax of the “cd -Path ... -PassThru” command. To do this work, you just need to type the following command in the PowerShell window and hit Enter. Then the current working directory of your PowerShell will be changed.
cd -Path D:\Ariel -PassThru
# 3. Windows PowerShell Change Directory Via the SL Alias
The “sl” cmdlet is another effective way that makes PowerShell navigate to folder. The syntax of the sl command works on the “sl -Path -PassThru”. Here’s an example of how to change directory in PowerShell using the sl command.
sl -Path D:\Ariel -PassThru
# 4. Windows PowerShell Change Directory Via the Chdir Alias
In addition to the above commands, you can use the chdir cmdlet which is also an alias of the Set-Location cmdlet. The syntax of the command is “chdir -Path .. -PassThru”. The following example shows you the process of the chdir cmdlet to change the current directory of PowerShell.
chdir -Path D:\Ariel -PassThru
Further reading: If you enter some issues like file system corruption and low disk space on Windows 10/11, don’t worry. MiniTool Partition Wizard can help you fix them easily by checking file system errors, extending/resizing partitions, analyzing disk space, upgrading to a larger hard disk, etc.