Sending test page to remote printer

Hi.

I’m have a tough time getting a command together that will send a test page to a print queue on a remote print server. Here’s what I’ve tried;

1:

(Get-CimInstance -computername PRINTSERVER1 -Classname Win32_Printer -Filter "Name Like 'print222'").printtestpage()

2:

Invoke-CimMethod -MethodName printtestpage -InputObject (Get-CimInstance win32_printer -Filter "name LIKE 'print222'")

3:

$GPC = Get-PrintConfiguration -ComputerName "PRINTSERVER1" -PrinterName "print222"

$o = $GPC | Out-Printer -Name ("\\PRINTSERVER1\print222")
$o

So far the only thing that works is this, but it has to be run locally, even then it seems to take forever to gather up the names of the printers on the server before it queues the test print job.

$p= Get-WmiObject win32_printer

foreach ($i in $p){
  If ($i.name -eq "print222"){
    $i.printtestpage()
    BREAK
  }
}

Does anyone have an way to send a test page to a printer on a remote print server, that doesn’t take a long time to complete the task? I would’ve thought this to be a pretty straight forward thing to do, but apparently not so much.

Thanks,
Dale

Hi, Everyone.

I was able to (somehow) figure this out. I had to play around with the cmd a bit to see what did and didn’t work, then build a cmd from there.

A little background:
My first attempts were either not working and would report that they did (see previous post with cmd examples), or they would take so long to run I thought the session was hung. I found if I ran the following cmd, it did work, but it had taken about 2 minutes to run as reported by Measure-Command:

invoke-command -computername server5 -ScriptBlock {Get-WMIObject -ClassName Win32_Printer -Filter "name like 'printer222'"}

Anything over 5 seconds is, in my opinion, too long. Then I found I can use the “-AsJob” flag and dramatically improve the speed of the cmd. The following is the winner for this problem as it only takes 2 seconds to send a test page to a remote print device hosted on a print server somewhere in the world.

invoke-command -computername $s -ScriptBlock {Get-WMIObject -ClassName Win32_Printer -Filter "name like $useing:p" -AsJob | Out-Printer -name ("\\"+$using:s+"\"+$Using:p)}

So, if anyone out there is looking to be able to send a test page to a remote print device, setup the vars for the printer server name ($s) and the name of the printer ($p), then use the above cmd.

Thanks,
Dale

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.