5

As per subject.

I've found some ways of scripting printer creation on Windows print servers using WMI, but it looks like WMI doesn't support clustered print servers (or clustered servers at all).

The scripts in C:\Windows\System32\Printing_Admin_Scripts are useless because, they are not cluster-aware and end up creating the printers on the active cluster node (just like using WMI).

The only tool I found that was able to work on a clustered print server is printui.exe (shortcut for rundll32 printui.dll, PrintUIEntry), but it can't create TCP printing ports: it can only add printers if the port already exists.

How can I completely script printer creation (including TCP printing ports!) on a clustered Windows Server 2008 R2 print server?

Massimo
  • 68,714
  • 56
  • 196
  • 319

4 Answers4

1

I don't know if this will work in a cluster enviornment, but there is the good old printbrm.exe tool. It creates what is essentially a cab file full of XML that can backup and restore printer setups between servers. This includes the dreaded TCP/IP ports. This might let you do a simple backup, modify the XML to add what you need and let you do a restore to your cluster. (Again, not sure if this is cluster aware).

Printbrm example: http://technet.microsoft.com/en-us/library/cc722360.aspx

rename the file to .cab and extract to disk...

The port file is brmports.xml. I suggest exporting out a printer or two to see how it is "supposed" to look.

MikeAWood
  • 2,566
  • 1
  • 12
  • 13
  • This conversation seem to indicate it might work.. http://social.technet.microsoft.com/Forums/en-US/winserverClustering/thread/1cb2a679-a805-478b-b5b2-458c5c98c539/ – MikeAWood Aug 03 '11 at 19:29
  • Useful, but my need is not to backup printers from a server and restore them on another one... I need to bulk-create them on a new server, starting from a printer list in CSV format. – Massimo Aug 04 '11 at 06:15
  • you could do that using this method, but you'd need to get the data for the printers in the proper format. By adding a few manually and exporting them out, it gives you the necessary driver cab files and examples for each printer def in XML... Remember its not just the ports, but the drivers as well (x86 and x64 in some cases for servers). This just simplifies the process, though its far from easy. Good Luck... – MikeAWood Aug 05 '11 at 08:40
  • I already installed all needed printer drivers, my problem is how to script the creation of actual printers (and printer ports). Looks like there's no working way do to that, though... :-/ – Massimo Aug 05 '11 at 09:21
  • You can, but you'd need to do it in XML. at least to use this tool... Can Powershell do it? Maybe something along the lines of this: http://blog.powershell.no/2009/11/07/bulk-create-printer-objects-on-print-servers-using-windows-powershell/ not sure if it will work for the cluster out of the box, but it might be worth a look... – MikeAWood Aug 05 '11 at 09:27
  • Tried, it doesn't work: WMI doesn't support clusters. – Massimo Aug 05 '11 at 10:10
0

The only way I was able to create ports first was with VBS and then use printui after the fact:

Set objWMIService = GetObject("winmgmts:")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objRAWPort.Name = "IP_192.168.1.2"
objRAWPort.Protocol = 1
objRAWPort.HostAddress = "192.168.1.2"
objRAWPort.PortNumber = "9100"
objRAWPort.Put_

Set objWMIService2 = GetObject("winmgmts:")
Set objNewPort2 = objWMIService2.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objLPRPort.Name = "IP_192.168.1.3"
objLPRPort.Protocol = 2
objLPRPort.HostAddress = "192.168.1.3"
objLPRPort.Queue = "MyQueue"
objLPRPort.ByteCount = True
objLPRPort.Put_

cmd = "rundll32 printui.dll,PrintUIEntry /if /b "PRINTER NAME" /f %windir%\inf\ntprint.inf /r "IP_192.168.1.2" /m "HP Color LaserJet 4550 PS" /Z

objCommandShell.Run cmd,,True

Might have some errors there but its the general idea.

Ryan
  • 161
  • 1
  • 4
-1

Have you seen this GPO setting?

Computer Configuration > Preferences > Control Panel Settings > Printers. Then right clicking going to New > TCP/IP Printer

Not familiar with cluster print servers, but that should work for you for TCP/IP print mapping.

Nixphoe
  • 4,524
  • 7
  • 32
  • 51
  • This is a server-side configuration... that GPO is for automatical printer configuration for users. – Massimo Jul 27 '11 at 16:56
  • They have the same setting under Computer Configuration. I corrected my answer to reflect that. Is that what you're looking for or am I totally not understanding the question? – Nixphoe Jul 27 '11 at 17:06
  • Totally unrelated, sorry. That's used for configuring client computers in a domain, while what I need instead is a scriptable way to configure a (clustered) print server; even if I choosed to apply that policy to a server, I'd still need to manually enter 200 printer ports... it would be easier to configure the server than the GPO. – Massimo Jul 27 '11 at 21:48