Example 2: Script containing Start-TpmsQueryByAgent
Description
Starts a query to retrieve printer information from target machines.
Requirement
- ThinPrint Clients
Syntax
Start-TpmsQueryByAgent -Servers <psobject[]>
Parameter | Description |
-Servers | list of target machines |
Example 1: cmdlet usage
The following example retrieves printer information from the computer list represented by the $server variable.
Start-TpmsQueryByAgent ($server)
Example 2: Script containing Start-TpmsQueryByAgent
The following script displays the printer lists from ThinPrint Clients which are defined in a .csv file.
- The definition file thinprint-clients.csv:
"Selected","Address" "1","192.168.209.203" "1","192.168.149.150" "1","192.168.149.14"
- The PowerShell script:
$allclients = @()
Import-Csv -Path .\thinprint-clients.csv | foreach {
if($_.Selected -eq 1)
{
$client = New-TpmsObjTpClient -Name $_.Address -Port 4000
}
$allclients += $client
}
$srva = New-TpmsObjQueryAgent -Name "cps47.ourdomain.local" -Port 5050 -ClientQueries ($allclients)
Start-TpmsQueryByAgent -Servers ($srva) | Format-TpmsDispatch
On the target machine cps47, Tpms.Agent connects to the ThinPrint Client addresses defined in thinprint-clients.csv and stores their information to $allclients.
printer lists retrieved from two ThinPrint Clients