# Step 1
# A V-Layer consists of both a pair of printers and a pair of printer ports. One printer uses a native driver (= native printer), the other uses TP Output Gateway as driver (= Output Gateway printer). After creating the printers, Tpms.Agent transfers the printer settings from a native printer template to the native printer and from there to the Output Gateway printer.
# Define a ThinPrint TCP/IP Port for the native printer (this will send the print jobs to the ThinPrint Client, here on client701):
$nativeport = New-TpmsObjTpPortTcp -Name Lexmark04: -TcpPort 4000 -BandwidthCtrl 100
# Define a Standard TCP/IP Port for the Output Gateway printer (this will send the print jobs to the native printer, that’s why its address is 127.0.0.1):
$tpogport = New-TpmsObjTcpIpPortRaw -Name Lexmark-TPOG: -PortNumber 9100 -HostAddress "127.0.0.1"
# Define the native printer with a template to retrieve printer settings (these will be transferred from the template to the native printer object and – in addition – to the Output Gateway printer object). The ThinPrint Client address (here, client701) with the printer ID (here, 61) is part of the printer name (alternatively this information can be written into the Windows registry using the -Usage parameter of Add-TpmsClientInfo):
$nativeprinter = New-TpmsObjPrinter -Name "PRN04-OVL#client701:61" -Driver "Lexmark T644 (MS)" -Port Lexmark04: -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.
# Define the Output Gateway printer (this is to be mapped into a user session):
$tpogprinter = New-TpmsObjPrinterTpog -Name "PRN04-OVL" -Port Lexmark-TPOG:
# Set the Output Gateway printer to be shared:
Add-TpmsSharingInfo -Printers ($tpogprinter) -Name "PRN04-OVL" -Mode Network
# Set the V-Layer pair (this will connect the Output Gateway printer to the native printer):
$vlayer = New-TpmsObjVLayerPair -Name "PRN04-OVL" -Printer "PRN04-OVL#client701:61"
# Step 2
# Specify the Tpms.Agent address (here, tpms002.ourdomain.local) with TCP port (5050) 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 ($nativeprinter,$tpogprinter) -Ports ($nativeport,$tpogport) -VLayerConnections ($vlayer)
# Step 3
# Send the specified data package to Tpms.Service which forwards it to the relevant Tpms.Agent. The agent will create ports and printers and connect the Output Gateway printer to the native printer:
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 V-Layers see Script containing New-TpmsObjVLayerPair.