Danlewis3 Posted March 12, 2010 Posted March 12, 2010 Good shutdown script dependent on the ou you pick OPTION EXPLICIT DIM cn,cmd,rs DIM objRoot DIM strRoot, strFilter, strScope ' ******************************************************************* ' * Setup ' ******************************************************************* ' Specify OU of computers you want to shutdown strRoot = "OU=IT Suites,dc=mine,dc=com" ' Default filter for computer objects ' You might want to use a different filter. By operating system for example: ' (&(objectCategory=Computer)(operatingSystem=Windows XP*)) strFilter = "(objectCategory=Computer)" ' Search child organizational units. Use "onelevel" to search only the specified OU. strScope = "subtree" ' ******************************************************************* SET cmd = CREATEOBJECT("ADODB.Command") SET cn = CREATEOBJECT("ADODB.Connection") SET rs = CREATEOBJECT("ADODB.Recordset") cn.open "Provider=ADsDSOObject;" cmd.activeconnection = cn cmd.commandtext = ";" & strFilter & ";" & _ "name;" & strScope '**** Bypass 1000 record limitation **** cmd.properties("page size")=1000 SET rs = cmd.EXECUTE WHILE rs.eof <> TRUE AND rs.bof <> TRUE wscript.echo "Shutting Down " & rs("name") & "..." ShutDownComputer(rs("name")) rs.movenext WEND cn.close ' Subroutine to shutdown a computer PRIVATE SUB ShutDownComputer(BYVAL strComputer) DIM strShutDown,objShell ' -s = shutdown, -t 60 = 60 second timeout, -f = force programs to close strShutdown = "shutdown.exe -s -t 60 -f -m \\" & strComputer SET objShell = CREATEOBJECT("WScript.Shell") objShell.Run strShutdown, 0, FALSE END SUB
danrhodes Posted March 12, 2010 Posted March 12, 2010 We use shutdownatron, it integrates with GP and works really well.
Danlewis3 Posted March 12, 2010 Author Posted March 12, 2010 i would rather have one on a scheduled task like you can with the above then if any one needs a computer suite leaving on longer you can change the task quicker than changing a group policy.
powdarrmonkey Posted March 12, 2010 Posted March 12, 2010 At the risk of derailing the thread (so my one and only post to it): i would rather have one on a scheduled task like you can with the above then if any one needs a computer suite leaving on longer you can change the task quicker than changing a group policy. Relevant doc: Shutdownertron - Administrator’s Guide. Additionally, Shutdownertron polls policy every minute to collect changes, so the maximum time by default is an hour and a half between updates (the time here is the policy update interval in Windows, 1 hour plus or minus a random offset of 30 minutes).
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now