Link to home
Start Free TrialLog in
Avatar of pjbonc
pjbonc

asked on

Routine to search through child ou's

I need this working script to do a little extra and drill down to the ou's under it and give me all computer accounts below the root. Right now it will return the computers in the path that I put in but I want it dynamically search all sub ou's  
On Error Resume Next 


Set objOU = GetObject("LDAP://OU=Something,OU=Something,OU=The,dc=Dark,dc=Side") 
objOU.Filter = Array("Computer") 

For Each objComputer In objOU 
	strComputer = objComputer.CN 
	' ===================================================================== 
	' Insert your code here 
	' ===================================================================== 






	Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
	Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
		For Each objOperatingSystem in colOperatingSystems
		ObjOperatingSystem.Reboot()
Next
	' ===================================================================== 
	' End 
	' ===================================================================== 
Next

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of rlandquist
rlandquist
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pjbonc
pjbonc

ASKER

it looks like it will do what i asked but i guess i forgot to mention that it needs to not prompt for any input. Where in this script would i put my code to execute? Would it go after the do until statement?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial