Powershell – Access already mapped network drive in PowerShell

powershellvmware-workstationwindows-server-2012

I am running a Windows Server 2012 installation inside VMWare Workstation. I have shared folders enabled, so drive Z: is mapped to \\vmware-host. I can correctly access this drive in Explorer (I can access Z: inside the "normal" `cmd) and I can properly open files.

I opened PowerShell and tried to to cd Z: and I got the following error:

cd : Cannot find path 'Z:\' because it does not exist.

Why can't PowerShell find the already mapped network drive?

I Googled a bit, and found the New-PSDrive command. I ran the following:

New-PSDrive -Name 'Z' -PSProvider FileSystem -Root 'Z:\'

but I still get the same error as above. What do I need to do to access the VMWare shared folders inside PowerShell.

Best Answer

You need to make the drive mapping available to the user you're running Powershell as. You can do the following to give that user the same drive mapping:

net use Z: "\\vmware-host\Shared Folders"

See the following SO question: Cannot access network drive in PowerShell running as administrator