Categories
Servers Windows Server

How to Access a Active Directory Network Share on a Non-Domain Joined PC

Sometimes you need to access a network share that requires an active directory authentication, but, you’re on a PC that’s not part of the domain. Saving the script below as a .bat file and replacing the parts that say “Server” with the actual name or IP of your server will allow your PC to access any network share with active directory credentials. Mostly, this is useful when you only need temporary access to a share, but don’t want to go through the whole network share mounting process.

@echo off

:: Remove ALL Existing Network Connections
net use * /delete /y

:: Auth with Domain Account
net use \\Server /u:DOMAIN\username

:: Open Network Shares
start \\Server

pause

Command Details:

@echo off

This will just tell the .bat file to not display the command line C:\users\username>.

net use * /delete /y

The first line will remove existing network connections you with the network shares you have accessed (if you already logged into another network share, it will remove the session from your PC and you will need to login to it again).

 net use \\Server /u:DOMAIN\username

This line will tell your computer to connect to the server’s network share using the account specified in the command. When you run this, it will prompt you to enter the password. Alternatively, you can hard code the password into the command, but that’s not recommended for security reasons.

start \\Server

This command will just open a window that will display all of the network shares that are available on the server. Just double click on one to open it and you should be good to go.

Known Issues:

If you have an Explorer window open to the share you’re trying to access (you tried navigating to \\Server, but it gave you a permission denied error). Make sure to close the window before running the .bat file, or it won’t work.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.