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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER