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
Bookmarks