On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = "Select Name, Location from 'LDAP://<strong>XXXXXXXXXXXXXXXXXXXXXXXXXXXX</strong>' " _
& "Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
'Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
'Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
txtPCName = objRecordSet.Fields("Name").Value
txtshutdown = "shutdown -t 15 -s -f -m \\" & txtPCName
set objShell = CreateObject("WScript.Shell")
objShell.Run txtShutdown
objRecordSet.MoveNext
Loop