Hi All. I have a script that tries and moves a user from the OU where they were created to the OU where they should reside based on company and department number. I can seem to get this to work as a script policy on "Post Create" but when the user is created and moved it throws an error to the user who is creating the account. There is no harm but an irritant. So I am trying to make this script work as a scheduled task with no sucess. Can Anyone help? Here is a short version of the script
Option Explicit
Set objHROU = GetObject ("LDAP://ou=HR Create Users,dc=brookshealth,dc=local")
For Each obj In objHROU
DirObj.Getinfo
objName=DirObj.Get("distinguishedName")
objcompany=DirObj.Get("company")
objdeptnum=DirObj.Get("departmentNumber")
strSourceObjectPath = "EDMS://" & objName
If objcompany = "Away" Then
strDestinationContainerPath = "EDMS://OU=RemoteCampus,OU=Users,DC=Home,DC=local"
Else
If objcompany = "Home" Then
Select Case objdeptnum
Case "01.6400"
strDestinationContainerPath = "EDMS://OU=MainCampus,OU=Users,DC=Home,DC=local"
Case "01.6401"
strDestinationContainerPath = "EDMS://OU=MainCampus,OU=Users,DC=Home,DC=local"
End Select
End If
End If
Dim ContainerObject
Dim NewObject
'Bind to the destination container
Set ContainerObject=GetObject(strDestinationContainerPath)
'Move the user
Set NewObject=ContainerObject.MoveHere(strSourceObjectPath, vbNullString)
Next