Map Drive: From Command Line =link=

net use Z: \\server\share /persistent:yes Once you set /persistent:yes , subsequent net use commands (without specifying persistence) will also be persistent until you turn it off with /persistent:no . Sometimes you need to access a share with alternate credentials while logged into Windows with your standard account. The /savecred flag stores the password for future sessions:

But for IT professionals, power users, and automation enthusiasts, the graphical approach is a bottleneck. It’s slow, inconsistent across remote sessions, and impossible to script. The command line—specifically net use and, more recently, PowerShell’s New-PSDrive —offers speed, precision, and repeatability. map drive from command line

net use * /delete While net use works everywhere, PowerShell offers richer control and better integration with modern authentication, including Azure AD and certificate-based logins. New-PSDrive for Persistent Mappings PowerShell’s drive cmdlets are primarily for creating session-scoped PSDrives (like HKLM:\ for the registry). However, with the -Persist flag, you can create a standard Windows mapped drive: net use Z: \\server\share /persistent:yes Once you set

net use Z: /delete To delete all mapped drives at once (common in logoff scripts): you can include the password directly:

net use \\server\share That’s right—you can net use a UNC path with no drive letter. It won’t appear as a drive, but it will be an authenticated, persistent connection that applications can still access via the full UNC path. Mastering net use and New-PSDrive turns drive mapping from a point-and-click chore into a scriptable, repeatable, and automatable operation. Whether you are deploying 200 workstations, maintaining a headless server, or simply tired of typing passwords into a dialog box, the command line offers speed, control, and depth that the GUI never will.

net use Z: \\server\share /user:DOMAIN\username * The asterisk ( * ) tells Windows to prompt for a password without echoing it to the screen. For fully automated scripts (use with caution), you can include the password directly: