PUSHD reminder - it automatically maps network drives
I've blogged a few times about how cool PUSHD (and POPD) is from the cmd.exe prompt. It's one of the most powerful "DOS" commands that few folks use.
PUSHD, of course, maintains a stack of where you are in your file system. It will PUSH a directory on the stack and move you there automatically. Combined with a PROMPT variable that includes (somewhere) a $+, you'll get a very powerful way to move about.
Example from CMD>EXE:
C:\Documents and Settings\Scott>PUSHD c:\windows
C:\Documents and Settings\Scott>
One thing that I don't see a lot is PUSHD with UNC Paths, and how it will automatically map a drive for you, starting at Z: moving backwrads and will unmap them when you POPD.
Example from CMD.EXE:
C:\Documents and Settings\Scott>PUSHD \\SCOTTPC\D
C:\Documents and Settings\Scott>cd \\scottpc\desktop
CMD does not support UNC paths as current directories.
But, of course, I can't CD to a UNC path with CMD.EXE.
However, all these scenarios, plus CD'ing to UNC paths work within Powershell:
PS C:\Documents and Settings\Scott> pushd \\scottpc\desktop
PS Microsoft.PowerShell.Core\FileSystem::\\scottpc\desktop> cd \\scottpc\d
PS Microsoft.PowerShell.Core\FileSystem::\\scottpc\d> cd \\scottpc\desktop
PS Microsoft.PowerShell.Core\FileSystem::\\scottpc\desktop> c:
PS C:\Documents and Settings\Scott> PUSHD \\SCOTTPC\D
PS Microsoft.PowerShell.Core\FileSystem::\\SCOTTPC\D> PUSHD \\SCOTTPC\DESKTOP
PS Microsoft.PowerShell.Core\FileSystem::\\SCOTTPC\DESKTOP> POPD
PS Microsoft.PowerShell.Core\FileSystem::\\SCOTTPC\D> POPD
PS C:\Documents and Settings\Scott> cd \\SCOTTPC\DESKTOP
Nice stuff to know. Thanks to Ryan Carr for the reminder.