Many Windows administrators encounter this puzzling scenario: Network drives mapped through Explorer or cmd.exe
become inaccessible in PowerShell sessions. This is particularly common with VMware shared folders mapped as network drives.
PowerShell runs in a separate session context from Explorer, and by default doesn't automatically map existing network drives. The key points:
- PowerShell doesn't inherit network drive mappings from Explorer
- The
New-PSDrive
command requires the UNC path, not the drive letter - VMware shared folders use special UNC paths (
\\vmware-host\
)
Here are three reliable methods to access your VMware shared folder in PowerShell:
Method 1: Direct UNC Path Access
The simplest solution is to use the full UNC path:
cd '\\vmware-host\Shared Folders'
Method 2: Permanent PSDrive Mapping
Create a persistent PowerShell drive mapping (survives sessions):
New-PSDrive -Name Z -PSProvider FileSystem -Root '\\vmware-host\Shared Folders' -Persist
Method 3: Automatic Drive Mapping in Profile
Add this to your PowerShell profile ($PROFILE
) for automatic mapping:
if (-not (Test-Path Z:)) {
New-PSDrive -Name Z -PSProvider FileSystem -Root '\\vmware-host\Shared Folders' -Persist
}
If you still encounter issues, verify these aspects:
- VMware Tools are properly installed and running
- Shared folder settings in VMware are correctly configured
- Check for network connectivity with
Test-NetConnection -ComputerName vmware-host
- Inspect existing drive mappings with
Get-PSDrive
- Using drive letters in
-Root
parameter (must use UNC path) - Forgetting the
-Persist
flag for permanent mappings - Attempting to map drives with administrative shares (like C$)
When working with VMware shared folders in Windows Server 2012, you might encounter a puzzling situation where mapped network drives (like Z:) are accessible in File Explorer and regular Command Prompt, but PowerShell claims they don't exist. This behavior occurs because PowerShell handles drive mappings differently from the Windows shell.
PowerShell operates in a separate session scope from the Windows shell. While traditional mapped drives (created via net use
or Explorer) are visible to the Windows shell, they aren't automatically available to PowerShell sessions. This is by design - PowerShell maintains its own drive provider system.
# This won't work for existing mapped drives
cd Z:
# Error: Cannot find path 'Z:\' because it does not exist
To access existing network drives in PowerShell, you need to either:
- Access them using their UNC path
- Create a proper PowerShell drive mapping
For VMware shared folders specifically, here's the correct approach:
# Option 1: Use UNC path directly
cd '\\vmware-host\Shared Folders'
# Option 2: Create persistent PSDrive mapping
New-PSDrive -Name Z -PSProvider FileSystem -Root '\\vmware-host\Shared Folders' -Persist -Scope Global
When working with VMware shared folders in PowerShell:
- Always use the actual UNC path (
\\vmware-host\Shared Folders
) rather than the mapped drive letter - The
-Persist
flag makes the mapping available across sessions -Scope Global
ensures the drive is visible to all scopes in the session- For scripting, UNC paths are more reliable than drive letters
Here's how to safely handle files on VMware shared folders:
# Reading a file
$fileContent = Get-Content '\\vmware-host\Shared Folders\config.ini'
# Writing to a file
'Server configuration' | Out-File -FilePath '\\vmware-host\Shared Folders\log.txt' -Append
# Directory listing
Get-ChildItem '\\vmware-host\Shared Folders\Projects'
If you still can't access the shared folder:
# Verify VMware tools are installed and running
Get-Service -Name VMTools
# Check network sharing settings
Get-SmbShare
# Test basic connectivity
Test-NetConnection -ComputerName vmware-host -Port 445
Remember that PowerShell remoting and VMware shared folders might require additional configuration if you're working across different authentication contexts.