Example 2: Script containing New-TpmsObjTpPortCon (for Native Printing)
Description
Defines a model for ThinPrint Connection Service Ports1. 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.
Requirements
- ThinPrint Engine
- Connection Service
- ThinPrint Clients (TCP/IP type)
TCP port directions with Connection Service printing
Syntax
New-TpmsObjTpPortCon -Name <string> -ConnectionService <string> -TcpPort <uint16> [-BandwidthCtrl <uint32>] [-IsEncrypted <boolean>] [-Compression <CompressionOpt>] [-PackageSize <uint32>] [-Scheme <SchemeVersion>] [-Version <uint32>]
Parameter | Description |
-Name | printer port name to be created; the port name must end with a colon ( : ), examples: CsPort: or "Cs Port:" |
-ConnectionService | address of the server the Connection Service is running on; see Connection Service address |
-TcpPort | TCP port to open a connection to the Connection Service (default: 4000); see TCP port |
-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. |
-IsEncrypted | enables SSL encryption (default: 0) 1: enabled 0: disabled |
-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 ClientId:PrinterId#PrinterName New: printer naming convention PrinterName#ClientId:PrinterId (default) see Naming convention |
-Version | optional: ThinPrint Port Monitor version (default: 151257685) |
ThinPrint Port settings: Connection Service port type (Con)
ThinPrint Port settings: Naming convention
Example 1: cmdlet usage
New-TpmsObjTpPortCon -ConnectionService "192.168.149.21" ' -TcpPort 4000 ' -BandwidthCtrl 500 ' -IsEncrypted 0 ' -Compression Default ' -Name Con:
Defines a ThinPrint Port with the denomination Con:, the print protocol Connection Service with the TCP port 4000, bandwidth limited to 500 kbit/s (kbps), no encryption and the default compression level.
Example 2: Script containing New-TpmsObjTpPortCon (for Native Printing)
The following script creates and shares a number of ThinPrint printers with native drivers – each with a ThinPrint Connection Service Port – here, with unlimited bandwidth. The printer information is retrieved from a specific ThinPrint Client via the Connection Service. The printer properties are retrieved from the templates of the relevant native drivers.
For each printer retrieved from the ThinPrint Client a relevant ThinPrint printer with a native driver as well as a ThinPrint Port is created.
$allports = @() $printers = @() $allprinters = @() $client = New-TpmsObjTpClient -Name "192.168.149.21" -Port 4000 -Uidx 88 $srva = New-TpmsObjQueryAgent -Name "cps47.ourdomain.local" -Port 5050 -ClientQueries ($client) $printerlists = Start-TpmsQueryByAgent -Servers ($srva) | Format-TpmsDispatch $portnum = 0 $printerlists | foreach { if ($_ -is [ThinPrint.Tpms.Common.TpSrcPrn]) { $printer = $_.Name $printerid = $_.Id $printers = New-TpmsObjPrinter -Name ([string]::Format("{0}#88:{1}", $printer, $printerid)) -Port ([string]::Format("ThinPort{0:D3}:", $portnum)) -Driver $_.DrvName -Template $_.DrvName Add-TpmsSharingInfo -Printers ($printers) -Name $_.Name -Mode Network $allprinters += $printers $allports += New-TpmsObjTpPortCon -ConnectionService "192.168.149.21" -TcpPort 4000 -Name ([string]::Format("ThinPort{0:D3}:", $portnum)) $portnum += 1 } else { $_ } } $srvb = New-TpmsObjApplyAgent -Name "cps47.ourdomain.local" -Port 5050 -Printers ($allprinters) -Ports ($allports) Start-TpmsApplyByAgent -Action Deploy -Servers ($srvb) | Format-TpmsDispatch
Start-TpmsApplyByAgent -Action Deploy creates ports and printers on the target machine and -Action Remove deletes them.
Note! Always run Add-TpmsSharingInfo together with New-TpmsObjPrinter or New-TpmsObjPrinterTpog – i. e., not with separate scripts.
ThinPrint Client with ID 88 connected to the Connection Service (running on 192.168.149.21)
Printers folder on the central print server: template printers before running the script
printers in the ThinPrint Client Manager of client with ID 88
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 ThinPrint Connection Service Ports created by the script above
1 Print data are sent – bandwidth controlled and compressed – via the Connection Service to ThinPrint Clients