Example 2: Script containing New-TpmsObjTpPortLpr
Description
Defines a model for an LPD type1 ThinPrint Port. The model is represented by a container that predefines all printer ports to be installed by Tpms.Agent in one variable.
Afterwards, this model can be used to define the target machine using New-TpmsObjApplyAgent and to perform the installation process using Start-TpmsApplyByAgent.
Note! Please also refer to the section Connecting printers to ThinPrint Ports.
Requirement
- ThinPrint Engine
path of print data with ThinPrint LPD printing
Syntax
New-TpmsObjTpPortLpr -Name <string> -Queue <string> [-Filter <char>] [-CompressData <boolean>] [-BandwidthCtrl <uint32>] [-PackageSize <uint32>] [-Version <uint32>]
Parameter | Description |
-Name | printer port name to be created; the port name must end with a colon ( : ), examples: LprPort: or "Lpr Port:" |
-Queue | printer queue name on a Linux or Unix machine or on a print server appliance; see Printer queue |
-Filter | if available, name a decompression filter installed on the (Linux or Unix) target machine; one character can be given (default: l, small letter); see LPD decompression filter |
-CompressData | switches data compression ON or OFF if a decompression filter can be used on a Linux or Unix machine 1: on 0: off see No data compression |
-BandwidthCtrl | bandwidth for printing limited to 1–10,000 kbit/s (kbps); see Bandwidth control; default: unlimited Up to installer version 1.0.53 or 1.0.61, the value had to be given in bps instead of kbps. |
-Compression | compression level {Disabled | Level0 | Level1 | BestSpeed | Level2 | Level3 | Level4 | Level5 | Level6 | Default | Level7 | Level8 | Level9 | BestCompression} For Level9 see Minimum print data volume |
-PackageSize | size of IP datagrams (in Byte) to be sent to the ThinPrint Client (default: 65535) |
-Scheme | Old: printer naming convention ClientAddress#PrinterName New: printer naming convention PrinterName#ClientAddress (default) see Naming convention |
-Version | optional: ThinPrint Port Monitor version (default: 151257685) |
ThinPrint Port settings: LPD port type (Lpd)
ThinPrint Port settings: Naming convention
Example 1: cmdlet usage
New-TpmsObjTpPortLpr -Name Lpd: -BandwidthCtrl 256 -Queue lp0 -Filter c -CompressData 1
Defines a ThinPrint Port with the denomination Lpd:, the print protocol LPR/LPD with bandwidth limited to 256 kbit/s (kbps), the target printer queue name Lp0, data compression ON and the decompression filter name c (on the target machine).
Example 2: Script containing New-TpmsObjTpPortLpr
The following script creates and shares a number of ThinPrint printers with native drivers – each with a ThinPrint LPD Port. The printer information is retrieved from the .csv file network-printers01.csv. The printer properties are retrieved from the templates of the relevant native drivers.
For each printer read from the definition file a relevant ThinPrint printer with a native driver as well as a ThinPrint Port is created.
- The definition file network-printers01.csv:
"Selected","PrinterName","PortName","Address","DriverName","TemplateName" "1","PRN01-BLN","PRN01-BLN:","192.168.209.203","Lexmark T644 Class Driver","Lexmark T644 Class Driver" "1","PRN02-OSL","PRN02-OSL:","192.168.149.129","HP Color LaserJet 9500 PCL6 Class Driver","HP Color LaserJet 9500 PCL6 Class Driver" "1","PRN03-STK","PRN03-STK:","192.168.130.98","HP Universal Printing PCL 6","HP Universal Printing PCL 6" "1","PRN04-KPN","PRN04-KPN:","192.168.143.36","OKI PCL6 Class Driver","OKI PCL6 Class Driver"
- The PowerShell script:
$allports = @() $printers = @() $allprinters = @() $portnum = 0 Import-Csv -Path .\network-printers01.csv | foreach { if($_.Selected -eq 1) { $allports += New-TpmsObjTpPortLpr -Name ([string]::Format("ThinPort{0:D3}:", $portnum)) -Queue Lp1 $printer = $_.PrinterName $address = $_.Address $printers = New-TpmsObjPrinter -Name ([string]::Format("{0}#{1}",$printer, $address)) -Driver $_.DriverName -Port ([string]::Format("ThinPort{0:D3}:", $portnum)) -Template $_.TemplateName Add-TpmsSharingInfo -Printers ($printers) -Name $_.PrinterName -Mode Network $allprinters += $printers $portnum += 1 } } $srva = New-TpmsObjApplyAgent -Name "cps47.ourdomain.local" -Port 5050 -Printers ($allprinters) -Ports ($allports) Start-TpmsApplyByAgent -Action Deploy -Servers ($srva) | Format-TpmsDispatch
Start-TpmsApplyByAgent -Action Deploy creates ports and printers on the target machine and -Action Remove deletes them.
Printers folder on the central print server: template printers before running the script
Printers folder on the central print server: template printers as well as four ThinPrint printers (with native drivers) created and shared by the script above
ThinPrint Port Manager: template printers connected to ThinPort: as well as ThinPrint printers connected to four LPD type ThinPrint Ports created by the script above
1 Print data are sent – bandwidth controlled – via the LPR/LPD protocol directly to Line Printer Daemons (LPDs)