How to map network drives using AD

I have been asked by my company to map drives using active directory but i have never had to do this before. At the moment i have created my own OU but i just dont know where to start. My knowledge on batch files is next to none and my knowledge on VB is even worse. I have managed to go into the logon template in the group policy for the OU but i am just lost on what to do.

Can you please help

Who is Participating?
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.

Brian PiercePhotographerCommented:
Use Group policy to ally a logon script to the OU, all users with accounts in the OU will then have the policy (and script) applied

Are you trying to ma the same drives for all users or different drives for different users ?
Here is a script I use to map drives and printers based on group membership. Just rename the case statements to the groups you want and the location of the shares. This should be a easy script for you to modify. Just apply this script as the login script under group policy.
I hope this helps. Good luck.

' VBScript to map drives based on group membership
On Error Resume Next
Set WshNetwork = CreateObject("WScript.Network")
DomainString = WshNetwork.UserDomain
UserString = WshNetwork.UserName
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
'unmap all drives
WshNetwork.RemoveNetworkDrive "V:",true,true
WshNetwork.RemoveNetworkDrive "W:",true,true
WshNetwork.RemoveNetworkDrive "X:",true,true
For Each GroupObject In UserObj.Groups
	Select Case GroupObject.Name
		Case "Group 1"
			WshNetwork.MapNetworkDrive "Z:", "\\<Server>\<Share>"
			wshNetwork.AddWindowsPrinterConnection "\\<Server>\<Share>"
		Case "Group 2"
			WshNetwork.MapNetworkDrive "Y:", "\\<Server>\<Share>"
		Case "Group 3"
			WshNetwork.MapNetworkDrive "X:", "\\<Server>\<Share>"
	End Select

Open in new window


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
Copy the line below, open notepad, paste the line below, save file as map.bat (save as  all files in notepad)
net use x: \\servername\sharename11 /persistent:yes
net use y: \\servername\sharename12 /persistent:yes
There are a few ways to do this, but for all users to get these mappings on logon, place the map.bat file into \\YourDomainControllerServername\netlogon\map.bat and set the users to run it automatically when they logon through their profile
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Good info about GPO local and AD setup

Depending on how many mapped drives you need the simples would be leegclystvale but that would be for everyone, like to a public share; a more complex mapped drives would be andrew_aj1 more like departmental drives.
ciscocharlieAuthor Commented:

Thank you all for your replies.  I will be looking at this when i go back to work but i have one more question, can you tell me how to publish network printers through the GPO  so that certain departments can access the printers i wont them too, would i have to use a .bat file??????

Thanks inadvance


Yes you could. Put a bat file in the Logon script part of the GPO for certain computers. You would need your AD OU structure to be organised by similar computers needing the specific printers or a common user OU.
GPO>User configuration>Windows settings>scripts>(logon/logoff)
Put your batch files in \\dcname\sysvol\scripts and then po0int your logon files in GPO to this location.
Hope that helps
My script above provides shares and printers by group names. hopefully that will work for you.
ciscocharlieAuthor Commented:

Thanks a lot for your last comment how would you create a batch file for the printers, i am a batch file novice.
This is the script that I use to map printers for teachers. I have it in a windows login batch file for my teachers GPO. Works great everytime. It set's the default printer as well to whatever printer number you like.


' PrinterSetDefault.vbs - Windows Logon Script.
' -----------------------------------------------------------'
Option Explicit
Dim objNetwork, strLocal, strUNCPrinter1, strUNCPrinter2, strUNCPrinter3, strUNCPrinter4
strUNCPrinter1 = "\\dhs01\BIC_OFFICE"
strUNCPrinter2 = "\\dhs01\BIC_COLOR"
strUNCPrinter3 = "\\dhs01\BIC_UPSTAIRS_PHOTO"
strUNCPrinter4 = "\\dhs01\BIC_DOWNSTAIRS_PHOTO"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection strUNCPrinter1
objNetwork.AddWindowsPrinterConnection strUNCPrinter2
objNetwork.AddWindowsPrinterConnection strUNCPrinter3
objNetwork.AddWindowsPrinterConnection strUNCPrinter4
objNetwork.SetDefaultPrinter strUNCPrinter1

Open in new window

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
Active Directory

From novice to tech pro — start learning today.