Bulk-create printer objects on print servers using Windows PowerShell
When installing a new print-server with several hundreds or thousands of printer objects there arent`t too much fun doing this manually.
Here are 3 steps to automate this process:
1) Install all the necessary printer drivers on the printserver
2) Create a csv-file with a listing of all printer objects and their properties
3) Bulk-import the printer objects using a script
For the 3rd step I`ve created a basic Windows PowerShell script, available on PoshCode.org from this link.
The script contains one function for creating a TCP/IP printer port and one function for creating a printer object. These functions are used in a foreach-loop cycling through the csv-file containing all the printer objects. The script are pretty basic, and should be further expanded with error handling and further details for printer properties.
The script are created and tested on a Windows Server 2008 server against a remote Windows Server 2003 server.
Running the script from Windows Server 2003 returns an access denied error, possibly due to the impersonation-model in Windows Server 2003. However, it should work from Windows Vista, Windows 7, Windows Server 2008 and Windows Server 2008 R2 against remote print-servers (2000/2003/2008/2008 R2).
Especially the ability to set NTFS permissions on the printer objects would be a useful addition in the script.
Please feel free to leave suggestions for improvements in the comments section below.
Update 09.11.2009:
I`ve got some feedback regarding the ability to set NTFS permissions on the printer objects in the script.
A utility called SubInACL from Microsoft could be used for this.
Example usage:
subinacl.exe /printer “\\print-server\printer” /revoke=”Power Users”
subinacl.exe /printer “\\print-server\printer” /grant=”DOMAIN\Domain Users”
The tool can be downloaded from here.