7.3. Navigating to Drives

You might have been wondering, from the examples you have seen so far, how we could use the cd command to switch to a new current drive. If you are an experienced cmd.exe user, you would not expect that to work—the cd command can only change to new directories on the current drive. Here is how that works when running cmd.exe:

C:\>cd d:\

C:\>

As you can see, the current drive remains set to C:. If you dig deeper, you will notice that cmd.exe keeps a "current" folder for every drive that it knows about. We can set the current folder to a drive other than the current one, and it will be available once we switch to that drive. For example, if we are currently in the C:\ location and cd to D:\tmp, we will change the current ...

Get Pro Windows PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.