This script is a little rough, I modified a script I use to log everybody off to a restart script.
dim ou
dim cn
dim ouarray
dim cnarray
dim objarray
dim objarray1
dim objarray2
dim objouarray
dim DomainName
dim split0
dim split1
dim FTPserver
dim localpath
dim start
dim dn
'BUILD CONFIG FILE -->
set objFS = CreateObject("scripting.FileSystemObject")
set objNewFile = ObjFS.CreateTextFile("computers.txt")
FTPserver = "server8.emerytelcom.com"
DomainName = "dc=emerytelcom,dc=com"
start = main(domainName)
function main(ldpath)
Set objOUS = GetObject("LDAP://" & ldpath)
For Each objOU In objOUS
objouarray = split(objOU.Name,"=")
split0=objouarray(0)
if split0 = "OU" then
objNewFile.WriteLine("'" & objou.Distinguishedname)
end if
split1=objouarray(1)
'BEGIN CN CONFIG -----------------------------------
if split0 = "CN" then 'if The object isn't a OU We assume it is a user,Group,or person.
'we need to test to see if the object is in fact a user we don't want to send to groups at this point.
objarray = split(objou.objectcategory,",")
objarray1 = split(objarray(0),"=")
objarray2 = objarray1(1)
'objNewFile.WriteLine(objarray2)
if objarray2 = "Computer" then
objNewFile.WriteLine("'\\" & split1)
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//" & split1 & "/root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
'
for each OpSys in OpSysSet
OpSys.Win32Shutdown 2
next
end if
end if
'BEGIN OU INTERATION ----------------------------------
if split0="OU" then
dn = objOU.DistinguishedName
'objNewFile.WriteLine()
' objNewFile.WriteLine()
'objNewFile.WriteLine()
' objNewFile.WriteLine()
' objNewFile.WriteLine()
'
' objNewFile.WriteLine(dn & "---------------------------------------------------------")
if dn <> "OU=Exchange Servers,DC=emerytelcom,DC=com" and dn <> "OU=Domain Controllers,DC=emerytelcom,DC=com" and dn <> "OU=COMPUTERS,OU=SERVERS,DC=emerytelcom,DC=com" and dn <> "OU=COMPUTERS,OU=CALL CENTER,DC=emerytelcom,DC=com"then
start = main(dn)
end if
end if
Next
end function
objNewFile.Close