Auto Mapping of multiple shared folders via Active Directory

Hello Experts,

I need an urgent support, my Boss told me to Map 4 shared folders to 300 users in our company so that when they login to their computers these 4 shared folders should be automatically mapped into their computers. I don't have any idea how to do this auto mapping of multiple shared folders via Active Directory. I am using windows 2008 as Domain controller and All users are using windows 7 workstations.

The 4 Shared folders which need to be automatically Mapped are:-
1) \\\Marketing$
2) \\\Sales$
3) \\\Home$
4) \\\Registration$

Experts please help me with an easiest solution because i don't know much about scripting and coding.

Thank you for the excellent support we are getting from all the "Experts" around the world from Expert-Exchange community.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony CarterCommented:
What you need is a script that has:

net use x: \\server_name\shared_directory_name

@echo off
net use * /delete /yes
net use m:  \\\Marketing$
net use n: \\\Sales$
net use o: \\\Home$
net use p: \\\Registration$

Save the script as logon.bat and save it to the domain controller's NETLOGON share.

The deploy with active directory:

1) Open Active Directory Users and Computers
2) Right click domain name at top left and click Properties > Group Policy > Edit > User Configuration > Windows Settings > Scripts (Logon/Logoff) > Logon > Add...
3) Enter path to logon.bat (e.g., \\domain.local\sysvol\domain.local\scripts\logon.bat) and click OK three times
4) Login from workstation. Drives m, n, o and p should appear in My Computer.

For AD 2008+ there is an alternative:
smpvmAuthor Commented:
Hello Anthony Carter,

Thank you for the support, I have about 2000 user in a OU, in which only specific 300 users should be linked with this script is that possible. i don't want this script to run for all the users in that OU because each users are belong to different departments.

Anthony CarterCommented:

Yes, you can create a group and put users in that group.  Your then make that group policy only applicable to that group (Group Policy Scope).

If you look at the following image:

You will see the Security Filtering section.  By default, Authenticated Users have this applied.  You can change this to a group of your choice (and management).

So essentially you create a new group policy, make the changes to execute the script, and modify the security filtering to your needs.

You could also use the following powershell script (instead of batch file):

(New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$($env:username)))")).FindOne().GetDirectoryEntry().memberOf

which returns the groups the logged in user is in.  Based on this, and case or if statements you can then mount drives using:

New-PSDrive –Name “K” –PSProvider FileSystem –Root “\\<machinename>\<share>” –Persist

Changing the path to the share and the drive letter (example above uses K).

Up to you how you want to implement this.  I am assuming that clients have windows 7 or above as otherwise powershell isn't installed by default.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.