• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

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?
0
rdvarghese
Asked:
rdvarghese
  • 2
1 Solution
 
RobSampsonCommented:
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.
0
 
rdvargheseAuthor Commented:
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 ?



0
 
RobSampsonCommented:
Yes, most of it is required, some is already taken care of by my script above, which I just reliased had a couple of erros in it, just typo's.  This would be your script to do both functions:
'==========
Option Explicit

Dim objNetwork, objFSO, objShell, objSysInfo, strUserName, objUser, arrOUs, arrMainOU
Dim objFolder, objFolderItem
Const ssfPERSONAL = 5

Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")

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

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

arrOUs = Split(objUser.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

' Now start the My Documents rename process
strUserName = objNetwork.UserName

Set objFolder = objShell.Namespace(ssfPERSONAL)
Set objFolderItem = objFolder.Self
objFolderItem.Name = "My Documents " & strUserName
'MsgBox objFolderItem.Name

'Clears Environment Cache
Set objNetwork = Nothing
Set objFSO = Nothing
Set objShell = Nothing
Set objUser = Nothing
Set objSysInfo = Nothing
Set objFolder = nothing
Set objFolderItem = nothing
'==========

Regards,

Rob.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now