cancel
Showing results for 
Search instead for 
Did you mean: 
5 Replies
tonyc66
New Member
New Member

Re: Schedule printer reboot

Jump to solution

I know this is an old thread, so hopefully someone who used this is still around.

The second script worked great for me, but I can't figure out how to format the printers.txt file to reboot multiple machines.  We have close to 20 in our organization and I'd prefer to reboot them all using a single PS script on a Sat night as opposed to 20 individual scripts run via multiple batch files, etc.

I tried one entry per line, and comma delimited.  I don't want to mess around too much trying as these are production machines and staff get annoyed when they have to wait for them to boot up to use them.

 

0 Kudos
Joe Arseneau
Valued Advisor
Valued Advisor

Re: Schedule printer reboot

Jump to solution

Thanks for correcting that, crossed mine out and redirected to you. Nice to have you back.

Please be sure to select "Accept Solution" and or select the thumbs up icon to enter Kudos for posts that resolve your issues. Your feedback counts!

Joe Arseneau
0 Kudos
klauskeys
New Member
New Member

Re: Schedule printer reboot

Jump to solution

Thank you very much! The second powershell script works for me.

 

I had already tested the first script (found on the web) without success.

 

Just to report my experience, I want to post the script in its final form: the one you have posted miss a parenthesis and the function position.

 

Here the correct script:

 

$SNMP = new-object -ComObject olePrn.OleSNMP

$ErrorActionPreference = "Continue"
<#Available choices for error action preference:
•SilentlyContinue – error messages are suppressed and execution continues.
•Stop – forces execution to stop, behaving like a terminating error.
•Continue - the default option. Errors will display and execution will continue.
•Inquire – prompt the user for input to see if we should proceed.
•Ignore – (new in v3) – the error is ignored and not logged to the error stream. Has very restricted usage scenarios.
#>

#reset the $error[0].Exception value on start and repeat on each loop
$error.clear()

#read from list
#return "Could not contact $_" if no response to ping
#return "Failed $_" if it connects but can not set the value
function setsnmp
{
$SNMP.open("$_","private",1,6000)
$SNMP.Set(".1.3.6.1.2.1.43.5.1.1.3.1",4)
}

Get-Content printers.txt | ForEach-Object {
if (Test-Connection $_ -Count 1 -Quiet) #test connection to ip with single ping
{
setsnmp
}
else {
Write-Output "Could not contact $_"
}
if ( $error[0].Exception -match "Exception calling")
{
Write-Output "Failed $_"
}
$error.clear()
}

#send snmp value
# setting the integer vaue "4" to oid ".1.3.6.1.2.1.43.5.1.1.3.1" using the "private" community name forces the printer to reboot

Tags (1)
Joe Arseneau
Valued Advisor
Valued Advisor

Re: Schedule printer reboot

Jump to solution

Asked a few colleagues, and was supplied with these 2 choices:

 

 

############## script start ##############

############## script start ##############

$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.10.10.1/properties/authentication/login.php");
# Post login to get new session id
$x = SendPOST ("http://10.10.10.1/userpost/xerox.set") ("_fun_function=HTTP_Authenticate_fn&NextPage=%2Fproperties%2Fauthentication%2FluidLogin.php&webUsername=admin&webPassword=password&frmaltDomain=default");

# Post reboot command with loggedin session id
$x = SendPOST ("http://10.10.10.1/userpost/xerox.set") ("_fun_function=HTTP_Machine_Reset_fn&NextPage=/status/rebooted.php");

############## script end ##############

 

 

 

or:

 

 Corrected version posted below by klauskeys

 

#powershell script to remotely reboot networked HP and Xerox printers
#ip values in plain text file printers.txt in the same directory as the script. ip's on separate lines.
#philgman@gmail.com

$SNMP = new-object -ComObject olePrn.OleSNMP
$ErrorActionPreference = "Continue"
<#Available choices for error action preference:
•SilentlyContinue – error messages are suppressed and execution continues.
•Stop – forces execution to stop, behaving like a terminating error.
•Continue - the default option. Errors will display and execution will continue.
•Inquire – prompt the user for input to see if we should proceed.
•Ignore – (new in v3) – the error is ignored and not logged to the error stream. Has very restricted usage scenarios.
#>

#reset the $error[0].Exception value on start and repeat on each loop
$error.clear()

#read from list
#return "Could not contact $_" if no response to ping
#return "Failed $_" if it connects but can not set the value
Get-Content printers.txt | ForEach-Object {
    if (Test-Connection $_ -Count 1 -Quiet) #test connection to ip with single ping
    {
        setsnmp
    }
     else {
        Write-Output "Could not contact $_"
    }
    if ( $error[0].Exception -match "Exception calling")
   {
        Write-Output "Failed $_"
   }  
   $error.clear()
   }

#send snmp value
# setting the integer vaue "4" to oid ".1.3.6.1.2.1.43.5.1.1.3.1" using the "private" community name forces the printer to reboot
function setsnmp 
{
$SNMP.open("$_","private",1,6000)
$SNMP.Set(".1.3.6.1.2.1.43.5.1.1.3.1",4)

 

 

 

Neither of these 2 options are mine, so I can't help with the specifics.

Please be sure to select "Accept Solution" and or select the thumbs up icon to enter Kudos for posts that resolve your issues. Your feedback counts!

Joe Arseneau
Joe Arseneau
Valued Advisor
Valued Advisor

Re: Schedule printer reboot

Jump to solution

There is not an official way to do so built in, but since you can reboot via CWIS on the Status tab, it would probably be simple for someone with a coding interest to build a tool that would send the same command from a PC daily at xx:xx time as a workaround.

 

For an official workflow it would need to go through what is called a FER (Feature Enhancement Request) through Xerox (Call for 2nd level and ask that a FER be submitted). There is absolutely no guarantee they would make one, but it is worth a shot if the feature is important enough to you.

Please be sure to select "Accept Solution" and or select the thumbs up icon to enter Kudos for posts that resolve your issues. Your feedback counts!

Joe Arseneau
0 Kudos
klauskeys
New Member
New Member

Schedule printer reboot

Jump to solution
Product Name: Other - specify product in post

Hi.

 

I need (to workaround an issue with badge readers and sleep resume) to schedule an automatic reboot of printers.

I'm working with WC 5875.

 

I found on the web powershell scripts to perform the reboot, but it's not  working on my devices.

 

There is a way to automatically reboot these printers?

 

Thanks in advance for support.

 

CLAUDIO

0 Kudos