net use Z: /delete To delete all mapped drives at once (common in logoff scripts):
For decades, the average Windows user has mapped network drives the same way: open File Explorer, right-click "This PC," select "Map network drive," pick a letter, type a path, and click "Finish." It’s visual, intuitive, and serviceable for the occasional connection. map drive from command line
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: net use Z: /delete To delete all mapped
Next time you need to map a drive, don’t open File Explorer. Open Command Prompt or PowerShell—and feel the difference. The /savecred flag stores the password for future
New-PSDrive -Name "Z" -PSProvider FileSystem -Root "\\server\share" -Persist This creates a drive visible in File Explorer and across all applications—identical to net use Z: \\server\share . PowerShell handles credentials more securely using PSCredential objects:
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: