Link to home
Start Free TrialLog in
Avatar of rdvarghese
rdvarghese

asked on

Microsoft, Windows Server, 2003, AD Based GPO

On the AD for our domain, we have a single Staff Group policy defined with a simple logon batch script. This script is used only for mapping drives.  Currently, the logon batch script maps like 7 different drives. (like accounting, services, contracts, ... etc)

How can i modify the script so that users in Accouting OU maps ONLY to the Accounting Folder.
so for Example:
Accounting - Maps only to Accounting Folder.
Services - Maps only to Services Folder.
Contracts - Maps only to Contracts Folder

i created different OU's for each department, but they all need new GPO's - because if i tried to link the existing Staff GPO, then it will still the use the old .bat file. I also tried setting up scripts based on each individual user properties on AD - under logon script- but that is not even getting executed. (made sure that no existing GPO policies are getting inherited or linked)

i am new to VBScripts. - Can this be done using Batch Scripts? is there a way to set an IF condition like
IF OU = "Accounting" then net use... or is that  doable only on a VB script?
Avatar of RobSampson
RobSampson
Flag of Australia image

Hi, paste the code below into a VBS file.  I do not think there is a way to do this with DOS.
'============
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objSysInfo = CreateObject("ADSystemInfo")
strUserName = objSysInfo.UserName

Set objUser = GetObject("LDAP://" & strUserName)

arrOUs = Split(objComputer.Parent, ",")
arrMainOU = Split(arrOUs(0), "=")

Select Case arrMainOU(1)
      Case "Accounting"
            If objFSO.DriveExists("F:") = False Then
                  objNetwork.MapNetworkDrive("F:", "\\server\Accounting")
            End If
      Case "Services"
            If objFSO.DriveExists("G:") = False Then
                  objNetwork.MapNetworkDrive("G:", "\\server\Services")
            End If
      Case "Contracts"
            If objFSO.DriveExists("H:") = False Then
                  objNetwork.MapNetworkDrive("H:", "\\server\Contracts")
            End If
End Select

Set objNetwork = Nothing
Set objUser = Nothing
'============

Regards,

Rob.
Avatar of rdvarghese
rdvarghese

ASKER

Thank you Rob.

Can the below code to rename mydocuments be included in the logon script ?
http://www.gpanswers.com/community/viewtopic.php?p=2094 

if so, would it go at the end ?



ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial