HI,
I'm working in an environnemnt where new users are constantly create in batch. I had previously run a script to create the userss home folders and set the appropriate permission for these users. Now with new users being created all the time, i woul like to have a script that will scan all my users, check to see if their homedrive fiel is empty, if yes, then the script will update the user homedrive settings, create the user folder on a specifics file servers, grant the appropriates permissions. In revanche i wont like to touch the old user settings
i have these scripts that i initially run the fisrt time. My problem is that i dont know how to combine these scripts to get them run without touching the my old users,but just update my new users settings.
Thanks
--Script 1
Query the OU members and create the users home directory
Set objOU = GetObject("LDAP://ou=users,ou=test,dc=test,dc=test,dc=ca"
ObjOU.Filter= Array("user"
For each objUser in ObjOU
Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objFolder = objFSO.CreateFolder("\\server\Users\"&objUser.SAMAccountName)
Next
--Script 2
Query the user to set the homedirectory path and the drive letter associated
Set objOU = GetObject("LDAP://ou=users,ou=test,dc=test,dc=test,dc=ca"
ObjOU.Filter= Array("user"
For each objUser in ObjOU
if Objuser.homeDrive = ""
Then
objUser.Put "homeDirectory", "\\server\users\"&objUser.SAMAccountName
objUser.Put "homeDrive", "P:"
objUser.SetInfo
--Script 3
Query the system file to set the appropriate permission
home = "\\server\Users"
Set ws = WScript.CreateObject("WScript.Shell"
Set fs = CreateObject("Scripting.FileSystemObject"
Set f = fs.GetFolder(home)
Set fc = f.Subfolders
For Each f1 in fc
Set objOU = GetObject("LDAP://ou=users,ou=test,dc=test,dc=test,dc=ca"
For each objUser in ObjOU
userHome = objUser.SAMAccountName
admin = "administrators"
system = "system"
username = Mid ( Ltrim(objUser.Name), 4, Len( objUser.Name ) )
userName2 = username & "@test.ca"
If Left(userName2,1) <> "_" and userName <> "Xrenee.lesage" Then
cmd = "cmd /c echo y| cacls " & home & "\" & userHome & " /c /g " & userName2 & ":f " & system & ":f " & admin &":f"
ret = ws.Run(cmd,0,true)
End If
Next
Next
Next
I'm working in an environnemnt where new users are constantly create in batch. I had previously run a script to create the userss home folders and set the appropriate permission for these users. Now with new users being created all the time, i woul like to have a script that will scan all my users, check to see if their homedrive fiel is empty, if yes, then the script will update the user homedrive settings, create the user folder on a specifics file servers, grant the appropriates permissions. In revanche i wont like to touch the old user settings
i have these scripts that i initially run the fisrt time. My problem is that i dont know how to combine these scripts to get them run without touching the my old users,but just update my new users settings.
Thanks
--Script 1
Query the OU members and create the users home directory
Set objOU = GetObject("LDAP://ou=users,ou=test,dc=test,dc=test,dc=ca"
ObjOU.Filter= Array("user"
For each objUser in ObjOU
Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objFolder = objFSO.CreateFolder("\\server\Users\"&objUser.SAMAccountName)
Next
--Script 2
Query the user to set the homedirectory path and the drive letter associated
Set objOU = GetObject("LDAP://ou=users,ou=test,dc=test,dc=test,dc=ca"
ObjOU.Filter= Array("user"
For each objUser in ObjOU
if Objuser.homeDrive = ""
Then
objUser.Put "homeDirectory", "\\server\users\"&objUser.SAMAccountName
objUser.Put "homeDrive", "P:"
objUser.SetInfo
--Script 3
Query the system file to set the appropriate permission
home = "\\server\Users"
Set ws = WScript.CreateObject("WScript.Shell"
Set fs = CreateObject("Scripting.FileSystemObject"
Set f = fs.GetFolder(home)
Set fc = f.Subfolders
For Each f1 in fc
Set objOU = GetObject("LDAP://ou=users,ou=test,dc=test,dc=test,dc=ca"
For each objUser in ObjOU
userHome = objUser.SAMAccountName
admin = "administrators"
system = "system"
username = Mid ( Ltrim(objUser.Name), 4, Len( objUser.Name ) )
userName2 = username & "@test.ca"
If Left(userName2,1) <> "_" and userName <> "Xrenee.lesage" Then
cmd = "cmd /c echo y| cacls " & home & "\" & userHome & " /c /g " & userName2 & ":f " & system & ":f " & admin &":f"
ret = ws.Run(cmd,0,true)
End If
Next
Next
Next