Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > shutdown computers in OU

Reply
Thread Tools Display Modes

shutdown computers in OU

 
 
Tom
Guest
Posts: n/a

 
      03-02-2009
hi,
does anyone have script for shutdown computers in certain OU in one domain?
 
Reply With Quote
 
 
 
 
Masterplan
Guest
Posts: n/a

 
      03-02-2009
Hi Tom,

You can export a list of computers from that OU with dsquery or csvde and
then use the shutdown command.

--
Have a nice day!
Masterplan - MCSE,MCITP-EA
http://winmasterplan.blogspot.com


"Tom" wrote:

> hi,
> does anyone have script for shutdown computers in certain OU in one domain?
>

 
Reply With Quote
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      03-05-2009

"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
--


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shutdown and reboot all domain computers nobody Scripting 2 11-05-2007 08:55 AM
shutdown or reboot all domain computers nobody Windows Server 4 10-29-2007 01:50 AM
Shutdown all computers that have no users logged in Col Active Directory 1 07-12-2007 09:44 AM
Shutdown computers Hen_ro Scripting 4 03-27-2006 11:24 AM
remotely shutdown computers in same ou Tom Server Networking 1 03-17-2005 03:23 AM



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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59