1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| PUBLIC net, fso, shell, temps
Set net = Wscript.CreateObject("WScript.Network" )
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set Shell = Wscript.CreateObject("WScript.Shell")
temps = 600
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://OU=Multipass,OU=Stations,DC=****,DC=*******,DC=com' " & "Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Set objShell = Wscript.CreateObject("Wscript.Shell" )
Do Until objRecordSet.EOF
ordinateur = objRecordSet.Fields("Name")
wscript.echo ordinateur
objShell.Run "cmd.exe /c psshutdown -u administrateur -p **** -s //"& ordinateur
' WScript.Echo "machine " & ordinateur & " en cours d'extinction."
' Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
' Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
objRecordSet.MoveNext
Loop |
Partager