How to Map Network Drives with PowerShell in Windows 11
You map a network drive in Windows 11 using PowerShell with commands like `New-PSDrive` to create persistent connections to network shares.
PowerShell is Windows’ powerful command-line shell and scripting language, perfect for automating system administration. Mapping a network drive lets you treat shared folders on other computers like local drives.
This makes accessing frequently used network resources much faster. You can assign specific drive letters, for example, mapping ‘Z:’ to a network path.
Use the New-SmbMapping cmdlet in PowerShell to map network drives persistently. Open PowerShell, then run New-SmbMapping -LocalPath “Z:” -RemotePath “\ServerNameShare” -Persistent $true, replacing “Z:” and the server path with your desired drive letter and network share.
Why Use PowerShell to Map Network Drives?
Why map network drives with PowerShell? It’s faster than clicking through menus, and it lets you automate connections for many computers at once. What happens when done? You gain a persistent network location that acts like a local folder, making file access seamless.
New-PSDrive vs New-SmbMapping
New-PSDrive vs. New-SmbMapping: It’s important to know the difference. New-PSDrive creates a drive that’s only available during your current session and might not appear in File Explorer. For persistent mapped drives that appear in Windows, use New-SmbMapping. You can find more details in the official Microsoft documentation.
UAC and Administrative Context
Mapped network drives might not show up for your regular user account if you mapped them using PowerShell as an administrator, due to Windows’ User Account Control (UAC).
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Value 1 -PropertyType DWord -Force
How to Map a Network Drive Silently
To map a drive without pop-ups, use the -SkipCredentialCheck or pre-stored credentials. You can also use Test-NetConnection to verify the server is reachable before mapping. This prevents errors during silent execution.
if (Test-NetConnection -ComputerName "ServerName" -Port 445) { New-SmbMapping -LocalPath "Z:" -RemotePath "\\ServerName\Share" -Persistent $true }Step 1Open PowerShell
Click the Start Menu and search for PowerShell. Then, select and open the app. Note: Do not run as administrator unless you need to change system settings.
Step 2Map the Drive
Use the New-SmbMapping command for a persistent network location that shows in File Explorer.
New-SmbMapping -LocalPath "Z:" -RemotePath "\\ServerName\Share" -Persistent $true
Step 3Check Existing Connections
To see your current network drives, use the following command:
Get-SmbMapping
Unmap or Disconnect Network Drives
To remove a specific drive, use the Remove-SmbMapping command.
Remove-SmbMapping -LocalPath "Z:" -Force
Summary
Mapping network drives with PowerShell is a handy way to manage shared folders and set them up to appear automatically.
Why does my PowerShell mapped drive not appear in File Explorer?
Your PowerShell mapped drive might not show up in File Explorer because commands like New-PSDrive often only work within that specific PowerShell session, or if you ran PowerShell as an administrator.
No comments yet — be the first to share your thoughts!