By David Wiseman (Administrator)Created 29 Jun 2009
My Rating:
Vote
Rating:
Not Rated
Views:6968
Downloads:137
Source:

Move Computers to OU

Language:  VBScript

Compatibility

Windows XP Yes Windows 2003 Yes
Windows 2000 Unknown Windows NT Unknown
Vista Unknown Windows 2008 Unknown
Description

Move all computers that start with "STU" to the students OU. The query can easily be modified to query for computers matching your own search criteria.

Code

Line Numbers: On  Off      Plain Text
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
strNewOU = "ou=Students,ou=All Computers,dc=wisesoft,dc=org,dc=uk"

' Modify the filter to query for your department.  
' This filter will find all computers where the name starts with "STU"
strSearchFilter = "(&(objectCategory=Computer)(sAMAccountName=STU*))"

' Specify a search root. The domain root is used by default. 
' e.g. dc=wisesoft,dc=co,dc=uk
' You could also specify a particular OU to start the search from.
' e.g. strSearchRoot = "ou=All Computers,dc=wisesoft,dc=org,dc=uk"
strSearchRoot = getDomainRoot

' A value of "subtree" will search all child containers (OUs).
' Change to "onelevel" if you don't want child containers to be 
' included in the search
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 = "<LDAP://" & strSearchRoot & ">;" & 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
	' Move user to new ou (passing the ADsPath attribute returned from the query)
	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

 


Got a useful script? Click here to upload!


 

  Post Comment
Order By:  
User Comments
      

Posted On: 9/28/2018 7:16:29 AM

jinyi928 pandora charms moncler outlet ugg boots outlet longchamp basketballl shoes adidas shoes bottega veneta mbt shoes supreme clothing coach outlet lacoste polo coach outlet christmas presents off white jordan adidas nmd longchamp outlet canada goose outlet canada goose outlet louboutin shoes canadian goose clarks outlet michael kors outlet skechers shoes new balance shoes canada goose moncler outlet coach outlet true religion salomon shoes off white shoes clarks outlet james harden shoes ray ban sunglasses ralph lauren polo pandora champion sportswear tory burch outlet coach outlet kate spade outlet michael kors outlet mlb jerseys nike tn ralph lauren polo oakley sunglasses true religion jeans champion clothing christian louboutin outlet christian louboutin shoes adidas superstar clarks shoes ralph lauren polo red bottom shoes pandora jewelry ralph lauren uk red bottom shoes moncler outlet canada goose jackets coach outlet coach outlet online canada goose outlet coach outlet converse trainer ecco shoes nike outlet superdry uk coach outlet online ugg outlet clearance canada goose outlet kate spade handbags adidas yeezy coach outlet jordan uk canada goose jacket hermes belt hogan shoes jordans ray ban sunglasses supreme ray ban sunglasses ray ban sunglasses true religion jeans outlet north face coach handbags ugg boots off white clothing canada goose ralph lauren polo christian louboutin shoes ralph lauren uk canada goose clothing coach outlet ugg outlet boots coach factory outlet air max 90 christian louboutin outlet christian louboutin off white outlet ugg outlet jordan shoes pandora charms asics shoes nike shoes outlet christian louboutin outlet moncler jackets ed hardy uk fitflops clearance ugg boots christian louboutin outlet michael kors outlet canada goose outlet pandora outlet tod's outlet manolo blahnik canada goose outlet red bottom shoes nike shoes salomon shoes nike blazers coach outlet dsquared2 ralph lauren fitflops clearance north face true religion jeans canada goose jackets pandora jewelry true religion jeans outlet jordans louboutin shoes asics shoes coach outlet nhl jersey jordan clothing yeezy boots 350 nike shoes nike shoes coach outlet online nike outlet factory jordan 8 fitflops clearance ralph lauren polo jordan shoes canada goose outlet jordan 4 adidas yeezy giuseppe zanotti kate spade outlet true religion canada goose nike clothing louboutin shoes nike air max mbt shoes issey miyake ferragamo belt air max 90 ultra boost 3.0 birken stock moncler outlet ugg boots canada goose outlet moncler outlet moncler jackets hogan shoes coach factory outlet louboutin shoes stussy ugg boots clearance true religion jeans soccer shoes pandora outlet pandora charms ugg boots ecco shoes canada goose outlet kate spade outlet jordan shoes nba jerseys reebok outlet adidas clothing louboutin shoes michael kors outlet fitflops clearance adidas clothing vibram five fingers coach outlet ray ban sunglasses nike shoes fidget spinner ralph lauren polo christian louboutin pandora jewelry coach outlet online pandora charms clarks shoes christian louboutin coach outlet coach outlet factory coach outlet kate spade outlet moncler jacket ugg outlet canada goose outlet mbt shoes ugg outlet ferragamo shoes valentino shoes red bottom shoes christian louboutin shoes pandora outlet prada handbags ralph lauren polo moncler outlet coach factory outlet coach outlet christian louboutin shoes kate spade outlet michael kors outlet ralph lauren polo longchamp outlet ralph lauren uk hermes belt coach outlet adidas outlet hugo boss kate spade nike shoes canada goose outlet hugo boss louboutin shoes jordan shoes prada shoes ugg boots clearance christian louboutin outlet supreme clothing ugg outlet air max 90 dsquared2 christian louboutin outlet christian louboutin nike huarache coach factory outlet

xiaoou
Posted On: 10/4/2018 3:25:15 AM

20181004 xiaoou stussy hoodie tory burch outlet online reebok shoes ugg boots clearance coach outlet online longchamp outlet store polo ralph lauren swarovski outlet store reebok shoes football shirts coach outlet online swarovski jewellery canada goose outlet puma shoes mulberry uk michael kors outlet mlb jerseys moncler jackets canada goose outlet store kobe shoes cheap ray ban sunglasses longchamp handbags true religion outlet uk christian louboutin shoes tods outlet online pandora charms sale clearance burberry outlet sale true religion jeans ugg boots clearance canada goose jackets uggs outlet canada goose jackets polo ralph lauren polo ralph lauren burberry canada cheap ray ban sunglasses canada goose jackets coach outlet online mlb jerseys ugg boots clearance kate spade outlet online michael kors outlet online adidas yeezy boost barbour women jackets canada goose jackets sale van cleef arpels jewelry cheap nhl jerseys michael kors outlet online cheap football shirts ray ban sunglasses outlet coach outlet online longchamp outlet online mizuno shoes asics running shoes ralph lauren polo ugg canada ferragamo shoes polo outlet factory store mont blanc outlet jordan 12 kd shoes bvlgari outlet canada goose coats nike air huarache cheap ugg boots ferragamo shoes canada goose outlet cheap jordan shoes coach factory outlet coach outlet nike outlet online nfl jerseys polo ralph lauren outlet true religion jeans ugg outlet uggs outlet uggs outlet supreme t shirts ralph lauren shirts cheap jordan shoes christian louboutin shoes true religion jeans sale kobe 9 elite coach outlet online coach outlet store pandora outlet nike outlet store coach outlet jordan 4 michael kors outlet online converse shoes sale cheap jordan shoes nfl jersey wholesale tory burch outlet online uggs outlet ugg boots clearance michael kors outlet christian louboutin shoes adidas nmd runner moncler coats coach outlet store online michael kors outlet clearance canada goose jackets nike shoes outlet christian louboutin shoes supreme t shirts ugg outlet michael kors outlet online air max 90 moncler jackets michael kors outlet clearance oakley sunglasses wholesale balenciaga shoes ugg boots clearance nike air max 1 ralph lauren uk denver broncos jersey ralph lauren polo coach outlet prada sunglasses for women coach factory outlet ugg outlet stores cheap ugg boots michael kors outlet swarovski outlet store cheap oakley sunglasses jordan shoes montblanc pens outlet nike air max soccer jerseys wholesale michael kors wallets for women ugg outlet michael kors bags nike roshe run chrome hearts online store ralph lauren polo michael kors outlet online ugg outlet canada goose outlet giuseppe zanotti shoes chrome hearts outlet store soccer cleats swarovski jewelry cheap oakley sunglasses canada goose outlet store fitflops shoes pandora jewelry hermes outlet store michael kors outlet online polo ralph lauren shirts canada goose coats ralph lauren outlet gucci outlet online coach outlet online cheap oakley sunglasses michael kors uk malone souliers moncler jackets cheap jordan shoes off-white clothing air jordan shoes polo ralph lauren shirts tory burch outlet online pandora charms sale clearance ralph lauren shirts tory burch outlet stores uggs outlet canada goose jackets outlet nike air huarache ugg outlet polo ralph lauren outlet michael kors outlet clearance ysl outlet online swarovski uk christian louboutin shoes suicoke sandals nike air max 90 adidas wings shoes coach factory outlet kate spade sale cheap soccer jerseys supreme t shirts michael kors canada coach outlet canada goose outlet store coach handbags outlet wellensteyn outlet canada goose outlet store longchamp handbags sale polo ralph lauren outlet red bottoms mbt christian louboutin shoes michael kors outlet ralph lauren polo mulberry bags michael kors outlet online ferragamo shoes air jordan shoes cheap jordan shoes cheap ray ban sunglasses cazal outlet michael kors outlet online kate spade handbags adidas shoes coach outlet store online louboutin shoes ugg boots on sale canada goose outlet store pandora charms sale clearance adidas store christian louboutin shoes coach outlet ferragamo outlet canada goose outlet store nike revolution air max 2015 los angeles lakers jerseys cheap oakley sunglasses nhl jerseys coach outlet tory burch outlet online mulberry handbags air jordan shoes christian louboutin outlet christian louboutin outlet moncler outlet online ugg outlet uggs outlet cheap jordan shoes michael kors outlet clearance michael?kors?outlet?online uggs outlet moncler outlet store north face outlet air force 1 shoes cheap ray ban sunglasses hermes birkin bag coach outlet online fred perry polo canada goose outlet store james harden shoes kate spade sale coach outlet online gucci bags fila sneakers michael kors outlet online adidas y3 shoes cheap ugg boots ed hardy outlet ugg outlet coach outlet michael kors outlet online ralph lauren outlet coach outlet online michael kors outlet lacoste shirts ugg boots clearance kate spade air jordan shoes ferragamo shoes nike shoes outlet coach outlet michael kors outlet online michael kors outlet online fitflops kate spade handbags michael kors outlet online michael kors outlet clearance ugg boots ugg outlet north face denail jacket clearance cheap jerseys wholesale oakley sunglasses wholesale oakley sunglasses wholesale mulberry outlet,mulberry handbags outlet fitflops tory burch handbags coach outlet online cheap jerseys wholesale cheap jordans yeezy boost uggs outlet pandora charms sale clearance herve leger dresses foamposite shoes ravens jerseys 49ers jersey canada goose jackets outlet canada goose outlet coach outlet online polo ralph lauren outlet jordan 3 jordan shoes uggs outlet michael kors outlet clearance michael kors factory outlet canada goose jackets manolo blahnik outlet moncler outlet online christian louboutin shoes birkenstock shoes adidas crazy mulberry handbags sale true religion outlet canada goose outlet online broncos jerseys cheap nba jerseys lebron shoes pandora charms sale clearance louboutin outlet burberry outlet store uggs outlet uggs outlet jordan 4 jordan shoes nike air force 1 kate spade handbags salomon outlet christian louboutin shoes swarovski outlet store nike uk store nobis jackets coach outlet burberry outlet online jordan retro cheap ray ban sunglasses fitflops sale clearance ugg boots clearance pandora outlet michael kors outlet clearance coach factory outlet michael kors handbags outlet air jordan retro christian louboutin shoes nike shoes outlet canada goose jackets true religion uk toms outlet uggs clearance hermes outlet store light up shoes christian louboutin shoes true religion jeans coach outlet online michael kors outlet online canada goose outlet pandora charms sale clearance longchamp pas cher michael kors outlet online mulberry handbags nike shoes outlet prada outlet online cheap nba jerseys uggs outlet christian louboutin shoes canada goose jackets new balance outlet coach outlet online canada goose outlet store cheap jordans kate spade sale michael kors outlet uggs outlet canada goose outlet store nfl jerseys mbt gucci outlet store undefeated shoes mcm backpacks texans jerseys canada goose outlet supreme clothing uk michael kors outlet online true religion outlet kobe bryants shoes christian louboutin shoes canada goose jackets uggs outlet cheap jordans free shipping true religion outlet ray ban sunglasses outlet canada goose jackets outlet tory burch outlet online air jordan shoes canada goose outlet store christian louboutin pas cher toms outlet coach factory store uggs outlet uggs outlet ray ban sunglasses outlet cheap jordans for sale air jordan shoes longchamp pliage longchamp pliage cheap ugg boots birkenstock shoes fitflops sale clearance marc jacobs sale canada goose outlet bottega veneta outlet online michael kors outlet online jordan shoes canada goose jackets pandora outlet coach outlet online coach outlet clearance chrome hearts online store christian louboutin shoes mishka snapbacks mulberry handbags adidas outlet online under armour outlet blackhawks jerseys pandora outlet moncler coats ralph lauren outlet coach outlet online true religion jeans pandora charms adidas nmd r1 coach factory outlet coach outlet canada goose jackets cheap nhl jerseys coach outlet online moncler outlet online pandora charms michael kors outlet online hermes belts pandora jewelry polo ralph lauren christian louboutin shoes mbt outlet cartier bracelet san antonio spurs tory burch outlet online louboutin shoes fitflops shoes vans sneakers nike factory store jimmy choo shoes coach factory outlet fitflops ralph lauren outlet ray ban sunglasses mulberry uk cheap basketball shoes cheap ray ban sunglasses true religion outlet coach factory outlet ugg outlet cheap oakley sunglasses coach handbags on sale 2018 world cup jerseys michael kors canada goose canada goose jackets givenchy handbags golden state warriors off white clothing cleveland cavaliers jerseys true religion outlet coach outlet longchamp outlet pandora jewelry camisetas futbol baratas cheap jordan shoes ugg boots clearance longchamp bags ugg outlet coach outlet canada goose outlet store kate spade sale christian louboutin shoes ugg boots tory burch outlet online cheap ray ban sunglasses longchamp handbags polo ralph lauren outlet michael kors outlet online nike shoes outlet fitflops sale clearance ray ban sunglasses outlet true religion outlet coach canada ugg outlet supra shoes sale lacoste polo cheap jordans canada goose outlet store ralph lauren outlet nike blazer pas cher michael kors uk adidas yeezy boost kate spade sale fitflops sale clearance pandora outlet kate spade handbags new york knicks links of london jewellery pandora charms sale clearance michael kors outlet clearance yeezy boost 350 nike air max 2017 michael kors handbags tory burch outlet online ferragamo shoes sale ralph lauren outlet pandora charms sale clearance ecco outlet gucci outlet online christian louboutin shoes ralph lauren femme coach outlet online north face outlet true religion outlet store kate spade outlet online polo outlet online snapbacks wholesale miu miu shoes prada shoes for men moncler outlet store toms outlet canada goose outlet store christian louboutin shoes true religion outlet ferragamo shoes ralph lauren polo canada goose jackets outlet adidas outlet online canada goose jackets nike air max 97 colts jerseys canada goose jackets pandora charms sale clearance cheap nba jerseys jordan shoes michael kors outlet online oakley sunglasses wholesale jordan retro canada goose jackets michael kors outlet clearance ugg boots gucci outlet online true religion outlet mbt coach outlet online mont blanc pens nike air max 90 coach outlet store cheap jerseys wholesale mulberry bags uggs outlet valentino shoes michael kors outlet online 20181004