Announcement

Collapse
No announcement yet.

Automatically rebooting all network PC's

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automatically rebooting all network PC's

    On my rounds I have noticed that a lot of people are not rebooting their PC's at night - Some have been up solid for 20 days +.

    Is there any way to schedule a reboot at say 01:00 every night. I cant find a GPO to do it and cant find a decent solution on google. The only way I can think of is to set-up a scheduled task and set it up on every PC

    Anyone else any better idea's

    All PC's are XP SP2
    Windows 2003 DC's

    Michael
    Michael Armstrong
    www.m80arm.co.uk
    MCITP: EA, MCTS, MCSE 2003, MCSA 2003: Messaging, CCA, VCP 3.5, 4, 5, VCAP5-DCD, VCAP5-DCA, ITIL, MCP, PGP Certified Technician

    ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

  • #2
    Re: Automatically rebooting all network PC's

    Code:
    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://DC=fabrikam,DC=com' " & "Where objectClass='computer'"  
    objCommand.Properties("Page Size") = 1000
    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
    Set objRecordSet = objCommand.Execute
    objRecordSet.MoveFirst
    
    Do Until objRecordSet.EOF
        strComputer = objRecordSet.Fields("Name").Value
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
    Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
    
    For Each objOperatingSystem in colOperatingSystems
        objOperatingSystem.Reboot()
    Next
    
        objRecordSet.MoveNext
    Loop
    This was just thrown together from the script centre, should do the trick I think. it just searches your AD for all computer accounts and sends a remote reboot command.

    topper
    * Shamelessly mentioning "Don't forget to add reputation!"

    Comment


    • #3
      Re: Automatically rebooting all network PC's

      Cheers topper,

      Looks like it will do the trick - Never though of scripting.

      You would have though there would be a group policy to enable this
      Michael Armstrong
      www.m80arm.co.uk
      MCITP: EA, MCTS, MCSE 2003, MCSA 2003: Messaging, CCA, VCP 3.5, 4, 5, VCAP5-DCD, VCAP5-DCA, ITIL, MCP, PGP Certified Technician

      ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

      Comment

      Working...
      X