How to use the cd command in Windows Powershell to change the drive that I am working

20

2

I read this answer but it doesn't work for Windows PowerShell. How to change the drive?

EDIT:
Please ignore this question. I was trying to change the drive from C: to D:. The reason it wasn't working was that there was no D: on my computer. A really silly mistake.

Aseem Bansal

Posted 2013-06-22T14:29:44.373

Reputation: 363

Question was closed 2013-06-23T00:52:47.770

1@Excellll It's not, the question you linked to talks about the native shell (cmd), not PowerShell. – Ohad Schneider – 2016-02-15T14:17:03.307

BTW, You should save as a *.ps1 file to run in PowerShell... i.e.

Set-Location C:\Folder
 – CZahrobsky  – 2016-08-30T21:34:54.287

possible duplicate of Using cd Command in Windows Command Line, Can't Navigate to D:∖

– Excellll – 2013-06-23T00:52:47.770

Answers

36

PowerShell will resolve full paths just fine with CD.

Where in DOS you have to /d for drive changing:

cd /d H:\Folder

PowerShell you can just type the full path:

cd H:\Folder

Austin T French

Posted 2013-06-22T14:29:44.373

Reputation: 9 766

0

It’s the same as the DOS shell “cd dir

Ben Lavender

Posted 2013-06-22T14:29:44.373

Reputation: 550

cd dir won't work if dir is on another drive. – Matthias Braun – 2018-10-11T09:52:56.593

Use the /d switch – Ben Lavender – 2018-10-14T20:25:57.723

Sure, that's what I gathered from Austin T French's answer. But having to add /d is not obvious at all (to me at least), meaning that information should be part of the answer. Put another way: cd dir is not the same as cd /d dir – Matthias Braun – 2018-10-15T09:16:57.560