pinkerton Posted October 9, 2012 Posted October 9, 2012 I need some help with a script I found here: Q and A - TechNet VB Script to move computers to specific OU I want to be able to move a rooms computers to a specific OU for controlled assessments, then use a similar script to move them back again. The script I have works only if used on the same domain as the PC's in question, trouble is, the script will need to be run from a teacher PC (staff domain) and move PC's on the pupil domain. Is it possible to specify a domain to look for in the script? I am a complete novice at scripting!
apeo Posted October 9, 2012 Posted October 9, 2012 Permissions aside, could you not just fill in strSearchRoot so you define the domain you want?.
pinkerton Posted October 9, 2012 Author Posted October 9, 2012 Hi, thanks for the reply. I have specified the OU + domain by adding this line: strSearchRoot = "OU=Classroom Pc's,OU=Senior School,OU=Managed Computers,DC=stbenedicts,DC=org,DC=uk" But I get an error: A referral was returned from the server, I'm pretty sure I have delegated control correctly. If I run the script still from the DC on the pupil domain the script works. Am I missing something?
apeo Posted October 9, 2012 Posted October 9, 2012 It should be: strSearchRoot = "DC=stbenedicts,DC=org,DC=uk"
pinkerton Posted October 9, 2012 Author Posted October 9, 2012 I am still getting the referral error, here is the script I am running: OPTION EXPLICIT Const ADS_PROPERTY_CLEAR = 1 DIM strSearchFilter, strSearchRoot, objRootDSE DIM cn,cmd,rs, strSearchScope DIM objNewOU, strNewOU ' ******************************************************** ' * Setup ' ******************************************************** ' Specify the distinguished name of the new OU to move the computers to strNewOU = "OU=ICT1,OU=Assesment with Word,OU=Controlled assessments,DC=stbenedicts,DC=org,DC=uk" ' Modify the filter to query for your department. ' This filter will find all computers where the name starts with "2SDS" strSearchFilter = "(&(objectCategory=Computer)(sAMAccountName=2SDS*))" strSearchRoot = "DC=stbenedicts,DC=org,DC=uk" strSearchScope = "subtree" set objNewOU = GetObject("LDAP://" & strNewOU) Set cn = CreateObject("ADODB.Connection") Set cmd = CreateObject("ADODB.Command") cn.open "Provider=ADsDSOObject;" Set cmd.ActiveConnection = cn cmd.CommandText = ";" & strSearchFilter & ";ADsPath;" & strSearchScope cmd.Properties("Page Size") = 1000 Set rs = cmd.Execute ' loop through the search results while rs.eof<> true and rs.bof<>true objNewOU.MoveHere rs(0),vbNullString rs.movenext wend rs.close cn.close wscript.echo "Completed" private function getDomainRoot ' Bind to RootDSE - this object is used to ' get the default configuration naming context ' e.g. dc=wisesoft,dc=co,dc=uk set objRootDSE = getobject("LDAP://RootDSE") getDomainRoot = objRootDSE.Get("DefaultNamingContext") end function
apeo Posted October 10, 2012 Posted October 10, 2012 Does this help: Error Code 8007202B - "A referral was returned from the server"
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now