Re: Script: Remote shutdown of all domain computers in spec. OU
- From: "FootBallUBet" <Doug.Stelley@xxxxxxxxx>
- Date: 27 Mar 2006 10:28:10 -0800
here's a quick script that will ask for the name of the OU in question
like "HOSTS"
then send if the resulting PC's are XP pro SP2 will send the command to
shutdown and reboot in 30 seconds
Const ADS_SCOPE_SUBTREE = 2
on error resume next
dim getOUname: getOUname = inputbox(" Enter name of OU, example HOSTS")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
Set objShell = CreateObject("WScript.Shell")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objRootDSE = GetObject("LDAP://RootDSE")
strRootDomain = objRootDSE.Get("rootDomainNamingContext")
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, operatingSystemServicePack, operatingSystem " & _
"FROM 'LDAP://OU=" & getOUname & "," & strRootDomain & "' " & _
"Where objectClass='computer' "
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
if objRecordSet.Fields("operatingSystem").Value = "Windows XP
Professional" then
if objRecordSet.Fields("operatingSystemServicePack").Value = "Service
Pack 2" then
objShell.Run ("C:\WINDOWS\system32\shutdown -r -f -t 30 -m \\" & _
objRecordSet.Fields("Name").Value) ,1,FALSE
end if
end if
objRecordSet.MoveNext
Loop
msgbox "done"
.
- References:
- Script: Remote shutdown of all domain computers in spec. OU
- From: Joris van der Struijk
- Re: Script: Remote shutdown of all domain computers in spec. OU
- From: FootBallUBet
- Script: Remote shutdown of all domain computers in spec. OU
- Prev by Date: Hiding mail enabled Contacts in specified OU from the address list
- Next by Date: Re: How to determine if logged on user is an Administrator?
- Previous by thread: Re: Script: Remote shutdown of all domain computers in spec. OU
- Next by thread: Re: Script: Remote shutdown of all domain computers in spec. OU
- Index(es):
Relevant Pages
|