# Step 1
# Specify the ThinPrint LPD Port with the queue name on the target machine (-Queue) and optionally with the bandwidth set to 100 kbit/s (-BandwidthCtrl). The port name must end with a colon ( : ) – here, Lexmark05:
$port = New-TpmsObjTpPortLpr -Name Lexmark05: -BandwidthCtrl 100 -Queue lp0
# Specify a printer name with the target address included (here, PRN05-TEM#192.168.209.204) 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 retrieve transfer its printer properties and settings to the printer to be created (-Template):
$printer = New-TpmsObjPrinter -Name "PRN05-TEM#192.168.209.204" -Driver "Lexmark T644 (MS)" -Port Lexmark05: -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, PRN05-TEM) and add this information to the same variable (-Printers):
Add-TpmsSharingInfo -Printers ($printer) -Name "PRN05-TEM" -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-TpmsObjTpPortLpr.