Change directory in PowerShell

Powershell

Powershell Problem Overview


My PowerShell prompt's 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".

Powershell Solutions


Solution 1 - Powershell

Unlike the CMD.EXE CHDIR or CD command, the PowerShell Set-Location cmdlet will change drive and directory, both. Get-Help Set-Location -Full will get you more detailed information on Set-Location, but the basic usage would be

PS C:\> Set-Location -Path Q:\MyDir

PS Q:\MyDir> 

By default in PowerShell, CD and CHDIR are alias for Set-Location.

(Asad reminded me in the comments that if the path contains spaces, it must be enclosed in quotes.)

Solution 2 - Powershell

To go directly to that folder, you can use the Set-Location cmdlet or cd alias:

Set-Location "Q:\My Test Folder"

Solution 3 - Powershell

Multiple posted answer here, but probably this can help who is newly using PowerShell

enter image description here

SO if any space is there in your directory path do not forgot to add double inverted commas "".

Solution 4 - Powershell

You can simply type Q: and that should solve your problem.

Solution 5 - Powershell

Set-Location -Path 'Q:\MyDir'

In PowerShell cd = Set-Location

Solution 6 - Powershell

You can also use the sl command to be able to change directories. It is Set-Location but it is much shorter.

Example:

# Too verbose
Set-Location -Path C:\

# Just the right amount of characters to type
sl C:\

Solution 7 - Powershell

If your Folder inside a Drive contains spaces In Power Shell you can Simply Type the command then drive name and folder name within Single Quotes(''):

Set-Location -Path 'E:\FOLDER NAME'

The Screenshot is attached here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSoConfusedView Question on Stackoverflow
Solution 1 - PowershellJeff ZeitlinView Answer on Stackoverflow
Solution 2 - PowershellBenHView Answer on Stackoverflow
Solution 3 - PowershellDeepeshView Answer on Stackoverflow
Solution 4 - PowershellCordo van SaviourView Answer on Stackoverflow
Solution 5 - PowershellRao AdnanView Answer on Stackoverflow
Solution 6 - PowershelljaycedotbinView Answer on Stackoverflow
Solution 7 - PowershellSibasis MohantyView Answer on Stackoverflow