1. Print queue names are same
2. The same named print queue is on the same IP address
The first one is normally easy. But the second one could be violated frequently due to support redirecting a print queue to an active printer, while a printer is in maintenance, without reverting back to correct IP address when the printer is back to normal.
The following script runs on any network server and generates a print queue discrepancy table. The table will list print server name, print queue name and IP address, for example:
SERVER1 | PRINTER1 | 192.168.100 |
SERVER2 | PRINTER1 | 192.168.101 |
SERVER1 | PRINTER4 | 192.168.104 |
SERVER2 | PRINTER4 | 192.168.105 |
Support can use the table to check and fix the discrepancies.
The PowerShell techniques used are:
1. Hash table. We have added print queue as the key and its IP address as the value into the hash table.
2. Hash table comparision. We compare the keys, and then compare the value of the same key on both print servers. Thanks for the reference here.
3. .NET System.Printing is used. This is used to get the Printer Port name from the queue. It is used due to its fast speed to get the queue objects.
4. .NET RegistryKey is used to retrieve print port IP address. This is used against PowerShell PS Drive due to its direct access to the item value.
As for the performance, it takes about 5 seconds to compare two print servers with 200 print queues each.
Thanks.
Script: PrintServerQueuesComparison.ps1