"Tom" <> wrote in message
news:28hnw148g8ko$.1gbzwobp77av6$... .
> hi,
> does anyone have script for shutdown computers in certain OU in one
> domain?
This link shows how to shutdown a computer in VBScript using WMI:
http://www.microsoft.com/technet/scr..._cpm_evqo.mspx
As long as you are only concerned with computers directly in the OU (not
those in any sub OU's), the VBScript program could be similar to:
=========
Option Explicit
Dim objOU, objComputer, objWMIService, colOperatingSystems
Dim objOperatingSystem, strComputer
Const SHUTDOWN = 1
' Bind to the OU object.
Set objOU = GetObject("LDAP://ou=Sales,ou=West,dc=MyDomain,dc=com")
' Filter on computer objects.
objOU.Filter = Array("computer")
' Enumerate all computers in the OU.
For Each objComputer In objOU
' Retrieve NetBIOS name of computer.
strComputer = objComputer.sAMAccountName
' Strip off the trailing "$".
strComputer = Left(strComputer, Len(strComputer) - 1)
' Bind to the WMI service on the remote computer.
Set objWMIService = GetObject("winmgmts: {(Shutdown)}" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem In colOperationgSystems
objOperatingSystem.Win32ShutDown(SHUTDOWN)
Next
Next
--
Richard Mueller
MVP Directory Services
Hilltop Lab -
http://www.rlmueller.net
--