# 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 Standard TCP/IP Port for the native printer (this will send the print jobs to the network printer):
$nativeport = New-TpmsObjTcpIpPortRaw -Name Lexmark03: -PortNumber 9100 -HostAddress "192.168.209.204"
# 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):
$nativeprinter = New-TpmsObjPrinter -Name "PRN03-PRA_n" -Driver "Lexmark T644 (MS)" -Port Lexmark03: -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 "PRN03-PRA" -Port Lexmark-TPOG:
# Set the Output Gateway printer to be shared:
Add-TpmsSharingInfo -Printers ($tpogprinter) -Name "PRN03-PRA" -Mode Network
# Set the V-Layer pair (this will connect the Output Gateway printer to the native printer):
$vlayer = New-TpmsObjVLayerPair -Name "PRN03-PRA" -Printer "PRN03-PRA_n"
# 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.