How to map network drives using AD

Hi,
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

Charlie
ciscocharlieAsked:
Who is Participating?
 
andrew_aj1Connect With a Mentor Commented:
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
Next
 
WScript.Quit

Open in new window

0
 
KCTSCommented:
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 ?
0
 
leegclystvaleConnect With a Mentor Commented:
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
0
Easily manage email signatures in Office 365

Managing email signatures in Office 365 can be a challenging task if you don't have the right tool. CodeTwo Email Signatures for Office 365 will help you implement a unified email signature look, no matter what email client is used by users. Test it for free!

 
choswootConnect With a Mentor Commented:
Good info about GPO local and AD setup
http://www.dedoimedo.com/computers/policies.html
http://calnetad.berkeley.edu/documentation/technical/gpmc/

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.
0
 
ciscocharlieAuthor Commented:
Hi,

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

Charlie

0
 
leegclystvaleCommented:
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
0
 
andrew_aj1Commented:
My script above provides shares and printers by group names. hopefully that will work for you.
 
0
 
ciscocharlieAuthor Commented:
Hi,

Thanks a lot for your last comment how would you create a batch file for the printers, i am a batch file novice.
0
 
HRSBTechConnect With a Mentor Commented:
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.

Matt




' 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
 
WScript.Quit

Open in new window

0
All Courses

From novice to tech pro — start learning today.