Windows

How to Map Network Drives with PowerShell in Windows 11

Richard
Written by
Richard
Jul 25, 2023 Updated May 1, 2026 2 min read
How to Map Network Drives with PowerShell in Windows 11

This guide explains how to map or disconnect network drives using PowerShell in Windows 11. Windows PowerShell is a tool that helps you automate tasks on your computer. It includes a command-line shell and a scripting language. The app comes built-in with Windows.

Why Use PowerShell to Map Network Drives?

Why map network drives with PowerShell? It is faster than clicking through menus and allows you to 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

It is important to know the difference. New-PSDrive creates a session-specific drive that often does not appear in File Explorer. For persistent mapped drives that show up in Windows, use New-SmbMapping. You can find more details in the official Microsoft documentation.

UAC and Administrative Context

Windows uses User Account Control (UAC) to separate standard and admin tasks. If you run PowerShell as an administrator, your mapped drives will not be visible to your standard user account. To fix this, you can enable linked connections. (Requires Admin Privileges)

💻Code
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.

💻Code
if (Test-NetConnection -ComputerName "ServerName" -Port 445) { New-SmbMapping -LocalPath "Z:" -RemotePath "\\ServerName\Share" -Persistent $true }

Step 1: Open PowerShell

Click on the Start Menu and search for PowerShell. Select and open the app. Note: Do not run as administrator unless you need to change system settings.

Step 2: Map the Drive

Use the New-SmbMapping command for a persistent network location that shows in File Explorer.

💻Code
New-SmbMapping -LocalPath "Z:" -RemotePath "\\ServerName\Share" -Persistent $true

Step 3: Check Existing Connections

To see your current network drives, use the following command:

PowerShell
Get-SmbMapping

Unmap or Disconnect Network Drives

To remove a specific drive, use the Remove-SmbMapping command.

💻Code
Remove-SmbMapping -LocalPath "Z:" -Force

Summary

Why use PowerShell? It provides a powerful way to manage network shares and automate drive assignments. What happens when you map a drive? You create a persistent link to a remote folder, allowing you to access files as if they were on your local machine. What happens when you unmap a drive? The connection is terminated, and the drive letter is removed from your system.

Why does my PowerShell mapped drive not appear in File Explorer?

If you use New-PSDrive, the mapping is often restricted to the current PowerShell session. Furthermore, if you run PowerShell as an administrator, the drive is created in a different security context than your user account. Use New-SmbMapping in a standard user window to ensure the drive appears in File Explorer.

Was this guide helpful?

Tags: #Windows 11
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

2466 articles → Twitter

📚 Related Tutorials

How to Map Local Folders as Drives in Windows 11
Windows How to Map Local Folders as Drives in Windows 11
How to Change PowerShell Execution Policies in Windows 11
Windows How to Change PowerShell Execution Policies in Windows 11
How to Open Windows Terminal as Admin Automatically
Windows How to Open Windows Terminal as Admin Automatically

Leave a Reply

Your email address will not be published. Required fields are marked *