Creating multiple Output Gateway printers on a single ThinPrint Port

28 views 0

# Retrieving printer information from a ThinPrint Client

# Step 1

# Specify a ThinPrint Client’s address and TCP port to retrieve the printer information from:

$client = New-TpmsObjTpClient -Name client701 -Port 4000

# Step 2

# Specify a Tpms.Agent address and TCP port to connect to the ThinPrint Client. Additionally, provide the ThinPrint Client information (-ClientQueries). Write the information to a data package (here, $srva):

$srva = New-TpmsObjQueryAgent -Name "tpms002.ourdomain.local" -Port 5050 -ClientQueries ($client)

# Step 3

# Send the specified data package to Tpms.Service which forwards it to the relevant Tpms.Agent. The agent will retrieve the printer information from the specified ThinPrint Client.

# Write the retrieved information to a variable (here, $clientprinters) to be able use it (below) for creating the relevant new printers. Format-TpmsDispatch displays the output in table form:

$clientprinters = Start-TpmsQueryByAgent -Servers ($srva) | Format-TpmsDispatch

# Creating printers

# Step 1

# Define the variables for the data package because multiple printers (or ports) are to be created (here, $allprinters and $allports).

$allprinters = @()

$allports = @()

# Create a program loop to add the information for multiple printers to the same variable:

$clientprinters | foreach {

if ($_ -is [ThinPrint.Tpms.Common.TpSrcPrn])

{

$printer = $_.Name

$printerid = $_.Id

$printers = New-TpmsObjPrinterTpog -Name ([string]::Format("{0}#client701:{1}", $printer, $printerid)) -Port ThinPort01: -Template "TP Output Gateway color"

Add-TpmsClientInfo -Printers ($printers) -Name client701 -Port 4000 -PrinterId $_.Id

Add-TpmsSharingInfo -Printers ($printers) -Name $_.Name -Mode Network

$allprinters += $printers

$allports = New-TpmsObjTpPortTcp -TcpPort 4000 -Name ThinPort01:

}

}

<#
  • $clientprinters contains the printer information of the ThinPrint Client (see # Step 3 of the section above). For each printer the loop must be run through.
  • if ($_ -is [ThinPrint.Tpms.Common.TpSrcPrn]) filters the printers from other informa­tion.
  • With $printer = $_.Name and $printerid = $_.Id the printer names and IDs from $cli­entprinters are written to individual variables.
  • $printers = New-TpmsObjPrinterTpog specifies an Output Gateway printer and buffers it in a variable.
  • -Name ([string]::Format(“{0}#client701:{1}”, $printer, $printerid)) spec­ifies the printer names according to the ThinPrint naming convention (here, the client address is cli­ent701): <client-printer-name>#<client-address>:<printer-ID>
  • If the template is on a remote machine, its name must be specified with FQDN address. Example: -Template “\\cps48.ourdomain.local\Lexmark T644 (MS)”.
    The service of the Tpms.Agent that creates the printers must run with an account that has the permis­sion to access the share of the template located on the remote computer.
  • With Add-TpmsClientInfo the properties of each printer will be retrieved from the ThinPrint Client (here, client701). This setting is added to the variable $printers.
  • With Add-TpmsSharingInfo sharing is enabled for each printer retrieved from the ThinPrint Client. The client printer name ($_.Name) is used as the share name. This setting is added to the variable $printers.
  • Finally, all printer and port data are stored in variables to prepare the data package (here, $allprinters and $allports). In this example, the already existing ThinPrint Port ThinPort01: is used as single printer port.

#>

# Step 2

# Specify the Tpms.Agent address (here, tpms002.ourdomain.local) with TCP port using New-TpmsOb­jApplyAgent and collect the relevant printer and port settings with the parameters -Printers and -Ports in a data package (here, $srvb):

$srvb = New-TpmsObjApplyAgent -Name "tpms002.ourdomain.local" -Port 5050 -Printers ($allprinters) -Ports ($allports)

# Step 3

# Send the specified data package to Tpms.Service which forwards it to the relevant Tpms.Agent. The agent will create the printers and connect them to the printer port:

Start-TpmsApplyByAgent -Action Deploy -Servers ($srvb) | Format-TpmsDispatch

Deploy enables this action – i. e., printer and port will be created. Remove disables it – i. e., printer and port will be deleted. Format-TpmsDispatch displays the output in table form.

Windows Print Management: five new printers and two Output Gateway templates – here, TP Output Gate­way color was used

For an example script with multiple ThinPrint Ports see Script containing New-TpmsObjPrinterTpog.

Previous Page
Next Page

Was this helpful?