Change directory in PowerShell

My PowerShell prompt is currently pointing to my C drive (PS C:>). How do I change the directory to a folder on my Q drive (PS Q:>)? The name of the folder on my Q drive is "My Test Folder."

+60
powershell
source share
5 answers

Unlike the CMD.EXE CHDIR or CD command, the PowerShell Set-Location cmdlet will change the drive and directory, both. Get-Help Set-Location -Full will give you more details about Set-Location , but the main use will be

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

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

( Assad reminded me in the comments that if the path contains spaces, it must be enclosed in quotation marks.)

+119
source share

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

 Set-Location "Q:\My Test Folder" 
+17
source share

A few answers are here, but this may probably help those recently using PowerShell

enter image description here

Therefore, if there is room in the directory path, be sure to add double quotation marks "".

+14
source share

Set-Location -Path 'Q:\MyDir' In PowerShell cd = Set-Location

+6
source share

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

+5
source share

All Articles