# Step 1
# Here, configuring a Standard TCP/IP Port as an LPR port is described.
# Specify the LPR port with the network printer’s (or Linux server’s) IP address (-HostAddress) and TCP port (-PortNumber) as well as the queue name on the target machine (-Queue). Optionally, the print job length can be calculated by spooling the job (-EnableByteCounting). The printer port name should end with a colon ( : ) – here, Lexmark02:
$port = New-TpmsObjTcpIpPortLpr -Name Lexmark02: -Queue lp0 -HostAddress "192.168.209.204" -EnableByteCounting 1
# Specify a printer name (here, PRN02-LSR) and a driver (here, Lexmark T644 (MS)) as well as the name of the port the printer is to be connected to. Here, the respective printer driver must already be installed on the target machine; this can be done manually or using New-TpmsObjDriver. Additionally, choose an existing printer as template to transfer its printer properties and settings to the printer to be created (-Template):
$printer = New-TpmsObjPrinter -Name "PRN02-LSR" -Driver "Lexmark T644 (MS)" -Port Lexmark02: -Template "Lexmark T644 (MS)"
# Note: 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 permission to access the share of the template located on the remote computer.
# Set the printer to be shared. On this, specify a share name using Add-TpmsSharingInfo (here, PRN02-LSR) and add this information to the same variable (-Printers):
Add-TpmsSharingInfo -Printers ($printer) -Name "PRN02-LSR" -Mode Network
# Step 2
# Specify the Tpms.Agent address (here, tpms002.ourdomain.local) with TCP port using New-TpmsObjApplyAgent and collect the relevant printer and port settings with the parameters -Printers and -Ports in a data package (here, $srv):
$srv = New-TpmsObjApplyAgent -Name "tpms002.ourdomain.local" -Port 5050 -Printers ($printer) -Ports ($port)
# Step 3
# Send the specified data package to Tpms.Service which forwards it to the relevant Tpms.Agent. The agent will create port and printer and connect the printer to the port:
Start-TpmsApplyByAgent -Action Deploy -Servers ($srv) | 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.
For an example script with multiple printers see Script containing New-TpmsObjTcpIpPortLpr.