7855 - Schedule Reboot - PowerShell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Andyyy41
    Technician
    • Nov 2012
    • 14

    #1

    7855 - Schedule Reboot - PowerShell

    Hi all. Not sure if this is the right place to ask. I have a fleet of 70+ 7855's and I want to schedule a reboot over the weekend automatically. I found a code for PowerShell to do this, but it doesn't seem to work.
    Code:
    $CookieContainer = New-Object System.Net.CookieContainer
    
    function SendGET([string]$url)
    {
    [net.httpWebRequest] $req = [net.webRequest]::create($url);
    $req.Method = "GET";
    $req.Accept = "text/html";
    $req.CookieContainer = $CookieContainer;
    [net.httpWebResponse] $res = $req.getResponse();
    $resst = $res.getResponseStream();
    $sr = new-object IO.StreamReader($resst);
    $result = $sr.ReadToEnd();
    return $result;
    }
    
    
    
    
    function SendPOST([string]$url, [string]$data)
    {
    $buffer = [text.encoding]::ascii.getbytes($data)
    [net.httpWebRequest] $req = [net.webRequest]::create($url)
    $req.method = "POST"
    $req.ContentType = "application/x-www-form-urlencoded"
    $req.ContentLength = $buffer.length
    $req.KeepAlive = $true
    $req.CookieContainer = $CookieContainer
    $reqst = $req.getRequestStream()
    $reqst.write($buffer, 0, $buffer.length)
    $reqst.flush()
    $reqst.close()
    [net.httpWebResponse] $res = $req.getResponse()
    $resst = $res.getResponseStream()
    $sr = new-object IO.StreamReader($resst)
    $result = $sr.ReadToEnd()
    $res.close()
    return $result;
    }
    
    
    
    
    # Request to get session id
    $x = SendGET ("http://10.64.135.52/properties/authentication/login.php");
    # Post login to get new session id
    $x = SendPOST ("http://10.64.135.52/userpost/xerox.set") ("_fun_function=HTTP_Authenticate_fn&NextPage=%2Fproperties%2Fauthentication%2FluidLogin.php&webUsername=admin&webPassword=1111&frmaltDomain=default");
    
    
    # Post reboot command with loggedin session id
    $x = SendPOST ("http://10.64.135.52/userpost/xerox.set") ("_fun_function=HTTP_Machine_Reset_fn&NextPage=/status/rebooted.php");
    Firstly, anyone PowerShell savvy know why? PS just says completed, but the machine is still on. Secondly, is there another way? I can'y seem to find one, but i haven't asked here yet.

    Any help much appreciated.

    Andy
  • Exok
    Senior Tech

    500+ Posts
    • Jun 2011
    • 750

    #2
    Re: 7855 - Schedule Reboot - PowerShell

    Program the machines to do a weekly on demand image overwrite on the weekend. Once its complete, the machines will reboot. You can set that in admin tools.

    Comment

    • davidL

      #3
      Re: 7855 - Schedule Reboot - PowerShell

      hi
      sorry if this is pointing out the obvious - are your devices still configured with default passwords??

      Comment

      • Andyyy41
        Technician
        • Nov 2012
        • 14

        #4
        Re: 7855 - Schedule Reboot - PowerShell

        Yeah they are. Hence why i put them in the script. The HDD wipe seems to be doing the trick at the moment, so thank you.

        Comment

        Working...