net use Z: \\server\share This maps the share \\server\share to drive letter Z: . If the share requires authentication, net use will prompt you for a username and password. But you can supply them inline for automation:
net use Z: \\server\share /user:DOMAIN\username MyPassword123 By default, a drive mapped via net use lasts only for the current user session. Log off, and it’s gone. To make a mapping persistent across reboots, add the /persistent:yes flag: map drive from command line
Next time you need to map a drive, don’t open File Explorer. Open Command Prompt or PowerShell—and feel the difference. net use Z: \\server\share This maps the share
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: Log off, and it’s gone