Labels

Showing posts with label Printing. Show all posts
Showing posts with label Printing. Show all posts

Friday, January 30, 2009

printQueue AD objects for 2003 Cluster

Print queue objects in AD provide a useful facility when users are trying to find printers, but with a 2003 MSCS clustered virtual print spooler, occasionally the information in AD does not reflect the current state of printers. This post describes some problems I've come across with duplicate/incorrect information and some ideas of how to automatically combat the problem.

Print Queue Objects in AD

Print queue objects in 2003 clustering are named with the virtual print server name, but they are children off a physical computer account. Which computer account the printers are children of is determined by the physical node that owned the cluster spooler resource when the printer was originally published in AD. As a virtual print server fails between nodes, the printer objects in the directory are not re-published (I assume unless the object is not found in the directory).

It's intuitive that print queue objects would be republished on failover to the node that currently owns the spooler, but that could potentially be hundreds or thousands of printer objects being created/deleted with each failover so it's practical not to. It appears the printer object is confirmed using the virtual print server name, and no change is made if the object is found - regardless of which physical node the print queue object is a child of.

In the scenario of a stand-alone printer server, when a printer is deleted, the spoolsv service also removes the directory object. In a clustered virtual print server this also occurs, however, it appears that in a 2003 cluster the object is not automatically removed from the directory if the node that owns the object when deleted is different than the publishing node.

None of this really matters if everything is working perfectly, but in a 2003 MSCS I have seen the following situations:

  1. Print queues that no longer exist still being visible through a search in AD
  2. Duplicate print queue objects, published against each physical none in the cluster that has hosted the virtual print spooler.

The first was a bigger problem, and I believe the following scenario will result in stale print queue objects persisting:

  1. You have a two node cluster, CL01 and CL02. CL01 owns a virtual print spooler and other cluster groups, under which you create all the print queues.
  2. At a later time you decide that the load could be better split, and move the virtual print spooler to CL02
  3. You then clean up your print queues from the virtual server, also expecting that they will be automatically removed from AD.

In the scenario above, the print queue objects would not be removed from AD, as the physical node that owns the spooler (CL02) does not own the original print queue objects - as they were created when CL01 owned the resources. In this state, the invalid print queue objects will not be purged. Note that this is assuming you aren't using AD printer pruning - by disabling the spooler service on your DCs or using Group Policy to control pruning.

I'm unsure of the exact scenario that caused the duplicate print queue objects, presumably there was some problem finding the existing record, so at some point it was created off the other node as well - resulting in duplicate results in a search (both of which would work, but still).

Some low maintenance ideas to correct this problem:

  1. Use AD printer pruning, which will ensure print queue objects in AD are managed. Note that this sounds like the obvious solution, but does have caveats and may not suit all environments.
  2. Periodically remove published records from all but the designated primary node, toggle the published attribute on those printers no longer having a record in AD, causing the printers to be republished against the primary node. This could easily be scripted and scheduled
  3. Modify printer creation change control processes to ensure that new printers are only created and deleted when the preferred owner is hosting the virtual print server

In an ideal world, three above followed by one make the most sense, but if you needed option two you could do something like this:

  1. dsrm CN=%virtual_server%-%QueueName%,CN=%physical_server%,DC=domainRoot
  2. cscript prncfg.vbs -s -b \\%virtual_server%\%QueueName% -published
  3. cscript prncfg.vbs -s -b \\%virtual_server%\%QueueName% +published
  4. dsquery * -limit 0 -filter "(&(objectClass=printQueue)(objectCategory=printQueue))" -attr cn printerName distinguishedname find /i "%QueueName%"

This removes the AD object against the 'incorrect' node, toggles the published flag (using prncfg from the Resource Kit Tools - see 'Network Printing Tools and Settings' reference below), and then queries AD to verify the printQueue object has been created.

Printer Pruning in AD

Pruning of printer objects in Active Directory is controlled either by the server that deletes the printer from its local spooler, or Domain Controllers through periodic printer pruning. Printer pruning is a domain/site-wide activity which processes all printQueue objects.

In a clustered solution, I believe when a Domain Controller looks up the printqueue objects, it will connect to the virtual print spooler node to verify the printers still exist. So regardless of which physical is publishing the printer, as long as the printer is contactable through the virtual server it shouldn’t be pruned.

As long as the spooler service is enabled on at least one Domain Controller, it will prune printers (at the default of 3x8 hour checks). There are risks of doing this, primarily that if the print server is down for longer than 24 hours (or if the DC can’t contact the server), all printers will be pruned from the directory. This logs an Event 50 for each pruned printer in the system event log of the DC that pruned the object - at least it’s easy to trace.

Printer Commands

Query and compare the printers published from each server to determine duplicates:

  • dsquery * "CN=%physical_server%,DC=domainRoot" -limit 0 -filter "(&(objectClass=printQueue)(objectCategory=printQueue))" -attr cn printerName driverName printCollate printColor printLanguage printSpooling driverVersion printStaplingSupported printMemory printRate printRateUnit printMediaReady printDuplexSupported > CL1.txt
  • dsquery * "CN=%physical_server%,DC=domainRoot" -limit 0 -filter "(&(objectClass=printQueue)(objectCategory=printQueue))" -attr cn printerName driverName printCollate printColor printLanguage printSpooling driverVersion printStaplingSupported printMemory printRate printRateUnit printMediaReady printDuplexSupported > CL2.txt
  • for /f "skip=1" %i in (CL1.txt) do @find /i "%i" CL2.txt

The following two commands help identify mismatches in printers published in AD versus those shared through the virtual print server.

Count the number of printers published in AD:

  • find /i /c "%virtual_server%" CL?.txt

The number of printers shared against a node:

  • rmtshare \\%physical_server% find /i "\\%virtual_Server%" /c

Query printers published against a physical server:

  • dsquery * "CN=%physical_server%,DC=domainRoot" -limit 0 -filter "(&(objectClass=printQueue)(objectCategory=printQueue))" -attr cn printerName driverName printCollate printColor printLanguage printSpooling driverVersion printStaplingSupported printMemory printRate printRateUnit printMediaReady printDuplexSupported

References:

Network Printing Tools and Settings
http://technet.microsoft.com/en-us/library/cc778201.aspx

Printer Pruner May Prune All the Print Queue Objects on Its Site
http://support.microsoft.com/kb/246906

Printer Pruner May Not Remove Printer Queue Objects from Active Directory
http://support.microsoft.com/kb/246174/

A server does not prune printers on a Microsoft Windows Server 2003-based server cluster
http://support.microsoft.com/kb/908128

Useful Windows Printer command-line operations:
http://waynes-world-it.blogspot.com/2008/09/useful-windows-printer-command-line.html

Wayne's World of IT (WWoIT), Copyright 2009 Wayne Martin.


Read more!

Sunday, September 21, 2008

Automatically mapping printers

A while back I came across one of the new 'features' in server 2003 R2, a method of centrally managing printers through the ‘Print Management’ snap-in, and then deploying those printers to workstations or users through a GPO.

This sounds clever, but I believe it's really just an automated method of creating a computer startup/user logon script, which uses a control file to determine which printers are to be installed and then runs a commandline utility to install those printers (pushprinterconnections.exe).

This made me reconsider the approach to managing printers for workstations, and similar or better functionality could be provided by one or more of the methods below:

  1. Use policy to deploy all printers for a building/floor/subnet to workstations. This would be the least management, but probably the least effective as there could be dozens or hundreds of printers per building/floor/subnet.
  2. Have a startup script that automatically adds a default printer when a user first logs on. The default would have to be either based on AD subnets and a mapping file between these subnets and default printers, or possibly based on user information such as location and department, which would be used to query AD/printer names to map appropriate printers, eg a user location of 'Building 1/Floor 2' and department of 'Finance' for a user could easliy be translated to a printer called FINPRINT1 with an AD location of 'Building 1/Floor 2'.
  3. Have a process that exports MAC/PCs connected per floor switch, which would be used as a control file to automatically map printers based on floor. This would typically require assistance from your friendly data communications team.
  4. Use 'DHCP snooping' to further identify where clients are coming from. For example, DHCP relay agent option 82 can be used to insert the switch MAC address/subscriber VLAN/port, SNMP information to the DHCP request packet (when using layer 2 DHCP relay agents as opposed to layer 3 ip helpers). This information could potentially be parsed by the DHCP server to identify the switch/port clients are coming from by parsing the circuit-id/remote-id. The output could be used as a control file to automatically map printers based on floor.
  5. Use the information from 4 and information on floor patching to construct a virtual map of your floors/buildings, which would place one or more workstations close to one or more printers, and map them automatically.
  6. When you build each workstation (this wouldn't work for roaming devices), create a control file that indicates physically where this workstation is located using the Microsoft format for subnet locations, eg Building/Floor 1/West Corner/Pod 4. Populate printer locations to this degree, and then your logon script could search the AD for matching printers and map those that are closest. You could also use this information to create a shortcut called 'Find printers' that uses 'rundll32 dsquery,OpenSavedDsQuery %Config%.qds' to open a saved query file that you've populated with this location. You would then need processes in place to update this control file as the workstation moves, otherwise it becomes incorrect - worse than nothing at all.
  7. Do nothing clever and let users add their own printers

Of course the 'nothing clever' option normally wins out, but in a large organisation one of the options above could add real value, and if done correctly would not be high maintenance.

References:

Manage Printers with New Group Policy Features in Windows Server 2003 R2
http://www.microsoft.com/technet/technetmag/issues/2006/08/ManagePrinters/

RFC 3046 - DHCP Relay Agent Information Option
http://www.faqs.org/rfcs/rfc3046.html

Configuring the DHCP Option 82 for Subscriber Identification
http://www.cisco.com/en/US/docs/switches/lan/catalyst3550/software/release/12.1_13_ea1/configuration/guide/swdhcp82.html



Wayne's World of IT (WWoIT), Copyright 2008 Wayne Martin.


Read more!

Monday, September 8, 2008

Useful Windows Printer command-line operations

The commands below are a subset of the complete command list found in Useful command-lines, and perform various operations against printers on a Windows 200x server.

The commands are useful for querying information from one or more printers, as well as making changes to configuration items for printers, including queues, shares, AD information and drivers. Generally Microsoft Windows printing is relatively simple - but add MSCS clustering, the plethora of PCL unidrv versions out there and badly written third-party drivers - troubleshooting can be quite difficult.

Each command-line can be copied and pasted at the command prompt, if you use a batch file you'll need to reference variables with double-percent (%%).



Use a custom WMIC alias to report printer info from a cluster node in CSV
wmic /node:"%server%" spoolerjobs list /format:table

Use a custom WMIC alias to report sorted HTML printer info from a cluster node
wmic /node:"%server%" spoolerjobs list /format:htable:"datatype=number":"sortby=TotalJobsPrinted"

Use a custom WMIC alias to report a brief summary of printer statistics
wmic /node:"%server%" spoolerjobs list brief /format:htable:"datatype=number":"sortby=TotalJobsPrinted"

Use a custom WMIC alias and xsl to sort print jobs output descending HTML table
wmic /node:"%server%" spoolerjobs list brief /format:"htabledesc-sortby.xsl":"datatype=number":"orderby=descending":"sortby=TotalJobsPrinted" > test.html

Reset inheritance starting at a folder and recursing
icacls \\UNC\Path /reset /t /c

Open a saved printer query window
rundll32 dsquery,OpenSavedDsQuery %Config%.qds

Query HP printers for the page count using SNMP
for /f %i in (Printers.txt) do @echo %i & @snmputil walk %i public printmib.prtMarker.prtMarkerTable.prtMarkerEntry.prtMarkerLifeCount | find /i "value"

Query printers for job counts >= 1
wmic /node:"%server%" path Win32_PerfFormattedData_Spooler_PrintQueue Where "Jobs>=1" Get Name,Jobs,MaxJobsSpooling,JobErrors,OutOfPaperErrors

Query printer information from AD (speed, memory etc)
dsquery * %serverDN% -limit 0 -filter "(&(objectClass=printQueue)(objectCategory=printQueue))" -attr cn printerName driverName printCollate printColor printLanguage printSpooling driverVersion printStaplingSupported printMemory printRate printRateUnit printMediaReady

Export printer information from AD (speed, memory etc)
csvde -f Printers.csv -d %serverDN% -r "(&(objectClass=printQueue)(objectCategory=printQueue))" -l cn,printerName,location,driverName,printCollate,printColor,printLanguage,printSpooling,driverVersion,printStaplingSupported,printMemory,printRate,printRateUnit,printMediaReady

Modify a printer or all printers on a print server to use the winprint processor
setprinter \\%Server%[\%Printer%] 2 pPrintProcessor="WinPrint"

Query the unidrv DLL versions from a list of pingable computers in an OU
for /f %i in ('"dsquery computer %OU_DN% -limit 0 -o rdn"') do @for /f "tokens=3 delims=: " %m in ('"ping -n 1 %i find /i "reply from""') do @for /f "tokens=1-9" %q in ('"filever \\%~i\C$\windows\system32\spool\drivers\w32x86\3\uni*.dll find /i /v "\\%~i""') do @echo %i,%q,%r,%s,%t,%u,%v,%w,%x,%y

check printers are being published in the directory through setprinter
setprinter -show \\%server% 7

Run the 32-bit version of regsvr32 on an x64 platform to register the prnadmin DLL
c:\WINDOWS\SysWOW64\regsvr32 c:\admin\util\prnadmin.dll

Run the 32-bit version of cscript that accesses a 32-bit DLL on x64
c:\WINDOWS\SysWOW64\cscript portmgr.vbs

Use SetPrinter to capture all settings for a printer
for %i in (0 1 2 3 4 5 6 7 8 9) do setprinter -show \\%server%\%printer% %i

Report print queue current length and various performance statistics
wmic /node:"%server%" path Win32_PerfFormattedData_Spooler_PrintQueue Get Name,Jobs,TotalJobsPrinted,TotalPagesPrinted,MaxJobsSpooling,JobErrors,OutOfPaperErrors

List printer drivers on a physical or cluster Windows 2003 server
cscript drvmgr.vbs -l -c \\%server%

Print a test page to one or more printers
for /f "tokens=1-4 delims=," %i in (%Printer.txt%) do cscript prnctrl.vbs -t -b \\%PrintServer%\%i

Given a list of printers, create an LPR port for each
for /f "tokens=1-4 delims=," %i in (%Printer.txt%) do @cscript portmgr.vbs -a -c \\%PrintServer% -p %i -h %k -t LPR -q %i

Given a list of printers, create a printer using the specified driver/port
for /f "tokens=1-4 delims=," %i in (%Printer.txt%) do @cscript prnmgr.vbs -a -c \\%PrintServer% -b %i -m "%j" -r %i

Given a list of printers, set the location, share name and publish in AD
for /f "tokens=1-4 delims=," %i in (%Printer.txt%) do @cscript prncfg.vbs -s -b \\%PrintServer%\%i -h %i -l "%l" +published

Given a list of printers, set glocal default printer properties to duplex
for /f "tokens=1-4 delims=," %i in (%Printer.txt%) do @setprinter \\%PrintServer%\%i 8 "pDevMode=dmDuplex=2,dmCollate=1,dmFields=duplex collate"

Given a list of printers, set printer permissions to allow for queue management
for /f "tokens=1-4 delims=," %i in (%Printer.txt%) do @c:\util\subinacl /printer \\%PrintServer%\%i /grant=%Domain%\%Group%=M

Find printer event log entries for the last 15 minutes
for /f %i in ('cscript //nologo c:\data\scripts\updated\time\finddatetime.vbs') do wmic /node:"%server%" path Win32_NTLogEvent WHERE "SourceName='Print' AND LogFile='System' AND EventCode=10 AND TimeGenerated > '%i'"

Find printer event log entries for the specified user
wmic /node:"%server" path Win32_NTLogEvent WHERE "SourceName='Print' AND LogFile='System' AND EventCode=10 AND User='%Domain%\\%Username%'" Get User,TimeGenerated,InsertionStrings

Automated Printer configuration
rundll32 printui.dll,PrintUIEntry /?

Create a port using prnadmin.dll on a cluster node
cscript portmgr.vbs -a -c \\%PrintServer% -p %Printer% -h %PrinterIP% -t raw -n 9100

Create a printer using prnadmin.dll on a cluster node
cscript prnmgr.vbs -a -c \\%PrintServer% -b %Printer% -m "HP Universal Printing PCL 6" -r %Printer%

Set printer configuration using prnadmin.dll on a cluster node
cscript prncfg.vbs -s -b \\%PrintServer%\%Printer% -h %Printer% -l "Building/Level 1" +published

Dump printer log entries
dumpel -s \\%PrintServer% -l System -e 10 -m Print -d 1

Add an x64 print driver to a cluster node
rundll32 printui.dll,PrintUIEntry /ia /c \\%PrintServer% /m "HP Color LaserJet 8550 PCL 5c" /h "x64" /v "Windows XP and Windows Server 2003" /f hpc8550t.inf

Add an x86 print driver to a cluster node
rundll32 printui.dll,PrintUIEntry /ia /c \\%PrintServer% /m "HP Color LaserJet 8550 PCL 5c" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003" /f hpc8550b.inf

Add to the permissions on a printer
subinacl /printer \\%PrintServer%\%Printer% /grant=%Domain%\%Group%=M

List the printers on a server
cscript "c:\Program Files\Windows Resource Kits\Tools\prnmgr.vbs" -l -c \\%PrintServer% find /i "printername"

Set the glocal default printer properties to allow duplexing
setprinter \\%PrintServer%\%i 8 "pDevMode=dmDuplex=2,dmCollate=1,dmFields=duplex collate"

Query the printers published against a specific computer account
dsquery * %ComputerDN%" -attr printShareName

Query all printers published in the Active Directory
dsquery * domainroot -filter "(objectCategory=printQueue)" -limit 0

Show the current default settings send down to clients from a printer
setprinter -show \\%printServer%\%Printer% 8

Find the print processor used by all printers on a print server
setprinter -show \\%server% 2 findstr /c:"pPrinterName" /c:"pPrintProcessor"

Check through SNMP whether a printer supports a duplexing media path
snmputil walk %printer% public printmib.prtMediaPath.prtMediaPathTable.prtMediaPathEntry.prtMediaPathDescription

Check through SNMP the printer device model
snmputil getnext %printer% public host.hrDevice.hrDeviceTable.hrDeviceEntry.hrDeviceDescr

View/Modify the ACL security on spooler pipe
pipesec \\%computer%\pipe\spoolss

Query printer tray configuration of printers on a cluster (HP UPD)
for /f %i in (Printers.txt) do @for /f "tokens=1,2,*" %m in ('"reg query \\%PrintServer%\HKEY_LOCAL_MACHINE\Cluster\Resources\%ClusterResourceGUID%\Parameters\Printers\%i\PrinterDriverData /v InputSlot 2>nul find /i "InputSlot" & if errorlevel 1 echo 1 2 NotFound"') do @echo %i,%o>>PrinterTrays.txt

Use SNMP to get the printer media path, indicating simplex/duplex capabilities
for /f %i in (Printers.txt) do @for /f "tokens=3,*" %m in ('"snmputil walk %i public printmib.prtMediaPath.prtMediaPathTable.prtMediaPathEntry.prtMediaPathDescription 2>nul find /i "value" & if errorlevel 1 echo 1 2 3 NotFound"') do @echo %i,%n



Wayne's World of IT (WWoIT), Copyright 2008 Wayne Martin.


Read more!

Thursday, August 14, 2008

Troubleshooting Windows Printing

While working with Windows client-server printing, at times I've had to troubleshoot what's happening beyond the 'oh that didn't work, let's try another driver' response.

I've tried to describe a few things in this post:

  1. An overview of the components responsible for printing from XP to a 2003 print server.
  2. Components that could contribute to problems, or at least provide angles of attack when troubleshooting
  3. All the (sometimes contractictory) Microsoft documents I've used to gather this information

Overview

This is my understanding of a standard print job from an XP client to a Windows Server 2003 print server, using:
- Excel as the client-side application
- The HP PCL6 Universal Printer Driver
- An x64 2003 print server, with an x86 XP client

  • XP ->
  • Excel Application ->
  • Graphics Device Interface (GDI) generates EMF ->
  • Client Print Driver renders the EMF ->
  • Client Spooler (winspool.drv) forwards EMF using RPC to the server ->
  • 2003 Server Spooler service (spoolsv.exe) determines correct driver to load and schedules job, API call to router ->
  • Print router (spoolss.dll) determines which provider to route the job (to the local print provider in this case) ->
  • Local Print Provider (localspl.dll) writes the job to a local Spool File (.spl) and Shadow File (.shd) ->
    1. Spool file (.spl) rendered using GDI -> UniDrv -> x64 HP UPD PCL6 Printer Driver -> GDI (driver loaded by spooler service)
    2. Shadow file (.shd) for adminsitrative job control
    3. Print Processor is polled for the job data type (to assist with reverse order, booklets etc). Default print processor (winprint.dll) used for HP UPD PCL6
  • Print Monitor ->
    1. Language Monitor provides bi-directional communication to receive feedback from the printer, using Printer Job Language (PJL)
    2. Remote Port Monitor (Standard TCP/IP Port Monitor) controls communication with the device

    Note that the above is a stand-alone 2003 server, in a 2003 MSCS clustered environment clusres.dll controls the print spooler resource and also has its finger in the pie.


    Troubleshooting Components

    Drivers

      1. PostScript
      2. PCL
        1. PCL5 vs PCLXL (PCL6)
        2. UniDrv.dll versions – the core Microsoft framework for non-PS/XPS printing
      3. For HP printers, HP Universal Driver vs Model specific driver

      Client

      1. Local printer driver versions
      2. Local unidrv.dll versions
      3. Application being printed from
      4. Page Setup within the application, especially for documents that may automatically re-size or use non-A4 paper.
      5. Workstation port/printer directly connected to the printer, rather than through the print server (using the HP UPD or whatever driver is failing through the print server)
      6. Print locally to file, and then copy the file to the printer, eg: copy test.prn \\server\printer - this bypasses any server-side actions, such as driver GDI or print processors
      7. Check that there are no differences when logged on as standard user compared to a local administrator

      Print Server

      1. 32-bit vs 64bit - if your print server is different architecture than your clients, have a test print server using the same architecture available to narrow the problem
      2. Cluster vs stand-alone server, if you're using an MSCS cluster, have a stand-alone print server available to narrow the problem
      3. Print Processor Used - winspool being part of localspl.dll, or a third-party print processor. I've seen problems with some HP print processors on x64 causing the spooler to crash
      4. Local unidrv.dll versions on both the client and server
      5. Local Printer driver versions on both the client and server
      6. Disabled Advanced printing features on the advanced tab of the printer
      7. Print directly to the printer on the advanced tab of the printer, rather than spooling through the server
      8. Check automatic configuration is working for the HP UPD printers (this relies on name resolution of the portname, and works better from the console of the print server if running x64)
      9. Print defaults such as duplex and collation
      10. Port Type – TCP ports either LPR (515), or RAW over 9100, depending on what the physical printer requires
      11. Port Configuration – LPR Byte counting (double-spooling) is a recommended setting if incomplete documents are being printed
      12. Check the Event log for successful print logs (Event ID 10), and note the byte count on multiple attempts at printing the same document. If the byte count is different for the same print job, the XP client is not sending through the same data each time and the print server has no chance. I have seen this happen with old various XP unidrv.dll versions.
      13. Set the print queue to hold print jobs, allowing copies of the SPL and SHD files to be taken, the PJL language commands in the SPL have useful information as such as the XP driver version used to generate the spool file
      14. Event 6161 errors occur on a cluster after a failed driver install/change to a printer. This does not seem to cause print jobs to fail (the error returned is 0 – error success), but I have seen this problem and it typically suggests an error in the GDI EMF part of the process

      Physical Printer

      1. Printer Personality type – Auto, PCL, or PCLXL
      2. Print defaults, such as whether Duplexing is on or off
      3. Firmware revisions

      Citrix

      1. Printer driver used – Citrix Universal or driver downloaded form client
      2. Presentation server version
      3. Different servers in the farm used for different connections
      References:

      From a Microsoft article on how network printing works, the first focuses on the client-side, the second on the server-side: How Network Printing Works:
      http://technet2.microsoft.com/WindowsServer/en/library/d58ce7b9-49cf-4f5e-95e9-1ade005c13e01033.mspx

      Upgrading the firmware with FTP:
      http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=bpj07129

      Download HP firmware:
      http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=bpj07429

      Printer personality:
      http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=c00018766&prodTypeId=18972&prodSeriesId=83436&locale=en_US

      UPD download v4.1:
      http://h20338.www2.hp.com/Hpsub/cache/342988-0-0-225-121.html

      Troubleshooting Event 6161 errors:
      http://technet2.microsoft.com/windowsserver2008/en/library/63a6432a-8d4d-47e7-a0b1-61ad2fe033b81033.mspx?mfr=true

      HOW TO: Programmatically Create a Printer and Printer Port by Using PrinterAdmin (Prnadmin.dll) with a Visual Basic Script in Microsoft Windows 2000
      http://technet2.microsoft.com/WindowsServer/en/library/f9aa2f5f-c66c-4474-be59-a684429f56c01033.mspx

      Print Services
      http://www.microsoft.com/windowsserver2003/technologies/print/default.mspx

      New command-line tools:
      http://technet2.microsoft.com/WindowsServer/en/library/4c475b4c-e5ee-444c-a730-ccb7a13e03b41033.mspx

      LPR versus RAW, RAW should be a good enough default, indicating the spooler does not modify the job as it passes the queue:
      http://technet2.microsoft.com/windowsserver/en/library/094f06f5-350d-4730-a283-2d131ae6e9af1033.mspx?mfr=true

      Creating and Configuring a Highly Available Print Server Under Microsoft Windows Server 2003 Using a Server Cluster
      http://www.microsoft.com/windowsserver2003/techinfo/overview/availableprinter.mspx

      Hp universal:
      http://h20000.www2.hp.com/bizsupport/TechSupport/ProductList.jsp?locale=en_US&taskId=135&prodTypeId=18972&prodSeriesId=503548

      Print Driver Setup: 64-bit Drivers and Platforms
      http://download.microsoft.com/download/5/D/6/5D6EAF2B-7DDF-476B-93DC-7CF0072878E6/multiplatform_INF.doc

      Printer Driver Setup and 64-bit Implications
      http://download.microsoft.com/download/f/0/5/f05a42ce-575b-4c60-82d6-208d3754b2d6/PrintDrv-Setup_64-bit.ppt

      FAQ for 64-bit Windows Hardware
      http://msdn2.microsoft.com/en-us/isv/bb190529.aspx

      Windows Point and Print Technical Overview
      http://download.microsoft.com/download/5/c/3/5c331f2d-3c1e-40b8-a2ec-0282c047d201/Pointandprint.doc

      HP document on MSCS clusters:
      http://h20338.www2.hp.com/Hpsub/downloads/HP_Drivers_in_Cluster_Environments.pdf

      The printer driver may not be updated on the client computers after you update the printer driver on a Windows Server 2003-based print server in a clustered environment
      http://support.microsoft.com/?id=888744

      HP Universal Print Driver For Windows Installation and Deployment Strategies (Based on Driver Version 3.0)
      http://h20000.www2.hp.com/bc/docs/support/SupportManual/c00954411/c00954411.pdf

      HP UPD FAQ
      http://h20000.www2.hp.com/bc/docs/support/SupportManual/c00858695/c00858695.pdf

      If HP printer, confirm the printer is supported by UPD:
      http://h20338.www2.hp.com/Hpsub/cache/344305-0-0-225-121.html

      Microsoft Word - UPD Active Directory Administrator Template Whitepaper.doc:
      http://h20000.www2.hp.com/bc/docs/support/SupportManual/c01034932/c01034932.pdf

      HP Color LaserJet printer prints only in grayscale or in black-and-white on your Windows 2000 SP4-based computer
      http://support.microsoft.com/kb/830490

      GPD files
      http://www.microsoft.com/whdc/archive/unidrv.mspx

      Installing a print processor
      http://msdn2.microsoft.com/en-us/library/ms802182.aspx

      Users cannot print after you install a service pack, update rollup, or printer hotfix on a server in Windows 2000 or in Windows Server 2003
      http://support.microsoft.com/kb/832219

      Event ID 9 — Print Queue Status
      http://technet2.microsoft.com/windowsserver2008/en/library/63cefbb6-03eb-42fc-b65d-8bf5d32af1b91033.mspx?mfr=true

      Windows Point and Print Technical Overview
      http://download.microsoft.com/download/5/c/3/5c331f2d-3c1e-40b8-a2ec-0282c047d201/Pointandprint.doc

      Printer driver versioning
      http://msdn2.microsoft.com/en-us/library/ms802210.aspx

      Unidrv Components
      http://msdn2.microsoft.com/en-us/library/ms801791.aspx

      SetPrinter Info
      http://msdn2.microsoft.com/en-us/library/ms535715(VS.85).aspx

      Debugging Printer Driver Components
      http://msdn2.microsoft.com/en-us/library/ms802162.aspx

      Print Service Product Operations Guide
      http://www.microsoft.com/technet/solutionaccelerators/cits/mo/winsrvmg/pspog/pspog5.mspx

      Common Printing Problems
      http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/prork/prdl_pif_zshs.mspx?mfr=true

      Local Print Provider
      http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/core/fnbe_prn_ycqq.mspx?mfr=true

      Setting print spooler options
      http://technet2.microsoft.com/windowsserver/en/library/b9e9cbfa-2db0-4fab-872f-65b9d73c6aa11033.mspx

      Installing Printer Ports
      http://technet2.microsoft.com/windowsserver/en/library/094f06f5-350d-4730-a283-2d131ae6e9af1033.mspx

      Network Printer Ports
      http://technet2.microsoft.com/windowsserver/en/library/290b7dc7-58ce-47a3-853b-8dd0ea5f4a621033.mspx?mfr=true

      Creating and Configuring a Highly Available Print Server Under
      http://download.microsoft.com/download/2/a/9/2a9c5a6b-472a-40b0-942f-3ba50240ccd9/ConfiguringAHighlyAvailablePrintServer.doc

      Using a Substitute Print Driver on x64 Systems
      http://www.microsoft.com/windowsserver2003/techinfo/overview/x64printdriver.mspx

      Printer Driver Setup and 64-bit Implications
      http://download.microsoft.com/download/f/0/5/f05a42ce-575b-4c60-82d6-208d3754b2d6/PrintDrv-Setup_64-bit.ppt

      FAQ for 64-bit Windows Hardware
      http://msdn2.microsoft.com/en-us/isv/bb190529.aspx

      Print Driver Setup: 64-bit Drivers and Platforms
      http://download.microsoft.com/download/5/D/6/5D6EAF2B-7DDF-476B-93DC-7CF0072878E6/multiplatform_INF.doc

      The printer driver may not be updated on the client computers after you update the printer driver on a Windows Server 2003-based print server in a clustered environment
      http://support.microsoft.com/?id=888744

      Printing - Architecture and Driver Support
      http://www.microsoft.com/whdc/device/print/default.mspx

      Windows 2000 and Windows Server 2003 Printing Architecture
      http://technet2.microsoft.com/WindowsServer/en/library/a8bfd078-2508-443b-9dc4-0a5fbd673f671033.mspx

      Wayne's World of IT (WWoIT), Copyright 2008 Wayne Martin.


      Read more!

      Friday, May 23, 2008

      Managing printers at the command-line

      This post provides a method of using the command-line to add printer drivers to a Windows 2003 print server, and then create and configure the port and printer. You can use this to create a control file with your printers, and then run these commands against the control file. There are also a few commands to gather information from your printer server(s) from the directory and event log.

      Adding a driver

      The printuientry calls have slightly different syntax between XP and 2003, hence the OS specific commands below even though the same print server is being targeted:

      The Driver model name should be extracted from the INF and replace the example HP UPD driver.

      On XP against a 32-bit print server:
      rundll32 printui.dll,PrintUIEntry /ia /c\\printserver /m "HP Universal Printing PCL 6" /h "Intel" /v "Windows 2000 or XP" /f \\server\drivers\hpupd_pcl6_x86\hpu4pdpc.inf

      On a 2003 x64 server, serving x86 clients (therefore both drivers are required):
      rundll32 printui.dll,PrintUIEntry /ia /c \\printserver /m "HP Universal Printing PCL 6" /h "x64" /v "Windows XP and Windows Server 2003" /f file://server/drivers/hpupd_pcl6_x64/hpu4pdpc.inf

      rundll32 printui.dll,PrintUIEntry /ia /c \\printserver /m "HP Universal Printing PCL 6" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003" /f \\server\drivers\hpupd_pcl6_x86\hpu4pdpc.inf

      Creating ports/printers

      Create a control file containing:
      <PRINTER_NAME>,<PRINTER_IP>,<PRINTER_DRIVER>,<PRINTER_LOCATION>

      For example:
      Printer1,192.168.0.10,HP Universal Printing PCL 6,Printer/Location/1

      Ping the IP Address for the printer:
      for /f "tokens=1-4 delims=," %i in (controlfile) do @echo. &@echo %i,%j,%k,%l &@ping -n 1 %j

      Register the prnadmin.dll if not already done:
      cd /d "C:\Program Files\Windows Resource Kits\Tools" && regsvr32 /s prnadmin.dll

      Assuming the driver is already installed, Add a DNS record create the port, Use the Microsoft Windows Resource Kit Tools to create the port and printer, configure the share and publish to AD, set duplex defaults, grant permissions to manage printers to a security group and ensure the print processor is winprint

      for /f "tokens=1-4 delims=," %i in (controlfile) do @echo dnscmd %ad_dns_server% /recordadd %domain% %i A %j

      for /f "tokens=1-4 delims=," %i in (controlfile) do @cscript portmgr.vbs -a -c \\printserver -p %i -h %j -t LPR -q %i

      for /f "tokens=1-4 delims=," %i in (controlfile) do @cscript prnmgr.vbs -a -c \\printserver -b %i -m "%k" -r %i

      for /f "tokens=1-4 delims=," %i in (controlfile) do @cscript prncfg.vbs -s -b \\printserver\%i -h %i -l "%l" +published

      for /f "tokens=1-4 delims=," %i in (controlfile) do @setprinter \\printserver\%i 8 "pDevMode=dmDuplex=2,dmCollate=1,dmFields=duplex collate"

      for /f "tokens=1-4 delims=," %i in (controlfile) do @c:\util\subinacl /printer \\printserver\%i /grant=domain\group=M

      for /f "tokens=1-4 delims=," %i in (controlfile) do @setprinter \\printserver\%i 2 pPrintProcessor="WinPrint"

      Print a test page to each printer:
      for /f "tokens=1-4 delims=," %i in (controlfile) do cscript prnctrl.vbs -t -b \\printserver\%i

      Check the printer is published in AD:
      for /f "tokens=1-4 delims=," %i in (controlfile) do dsquery * CN=printserver,OU=ServerOU,DC=domain,DC=com -filter "(&(printShareName=%i))"

      Note that subinacl.exe in the rktools isn't very functional, 5.2.3790.1180 is much better:
      http://www.microsoft.com/downloads/details.aspx?FamilyID=E8BA3E56-D8FE-4A91-93CF-ED6985E3927B

      Gathering information from a print server

      Export Print Server details:
      dsquery * OU=ServerOU,DC=domain,DC=com -limit 0 -filter "(&(objectClass=printQueue)(objectCategory=printQueue))" -attr cn printerName driverName printCollate printColor printLanguage printSpooling driverVersion printStaplingSupported printMemory printRate printRateUnit printMediaReady

      csvde -f PrinterDetails.csv -d OU=ServerOU,DC=domain,DC=com -r "(&(objectClass=printQueue)(objectCategory=printQueue))" -l cn,printerName,location,driverName,printCollate,printColor,printLanguage,printSpooling,driverVersion,printStaplingSupported,printMemory,printRate,printRateUnit,printMediaReady
      Dump event logs for the last day:
      c:\util\dumpel -s \\printserver -l System -e 10 -m Print -d 1

      Wayne's World of IT (WWoIT), Copyright 2008 Wayne Martin.


      Read more!

      All Posts

      printQueue AD objects for 2003 ClusterVirtualCenter Physical to VirtualVirtual 2003 MSCS Cluster in ESX VI3
      Finding duplicate DNS recordsCommand-line automation – Echo and macrosCommand-line automation – set
      Command-line automation - errorlevels and ifCommand-line automation - find and findstrBuilding blocks of command-line automation - FOR
      Useful PowerShell command-line operationsMSCS 2003 Cluster Virtual Server ComponentsServer-side process for simple file access
      OpsMgr 2007 performance script - VMware datastores...Enumerating URLs in Internet ExplorerNTLM Trusts between 2003 and NT4
      2003 Servers with Hibernation enabledReading Shortcuts with PowerShell and VBSModifying DLL Resources
      Automatically mapping printersSimple string encryption with PowerShellUseful NTFS and security command-line operations
      Useful Windows Printer command-line operationsUseful Windows MSCS Cluster command-line operation...Useful VMware ESX and VC command-line operations
      Useful general command-line operationsUseful DNS, DHCP and WINS command-line operationsUseful Active Directory command-line operations
      Useful command-linesCreating secedit templates with PowerShellFixing Permissions with NTFS intra-volume moves
      Converting filetime with vbs and PowerShellDifference between bat and cmdReplica Domain for Authentication
      Troubleshooting Windows PrintingRenaming a user account in ADOpsMgr 2007 Reports - Sorting, Filtering, Charting...
      WMIC XSL CSV output formattingEnumerating File Server ResourcesWMIC Custom Alias and Format
      AD site discoveryPassing Parameters between OpsMgr and SSRSAnalyzing Windows Kernel Dumps
      Process list with command-line argumentsOpsMgr 2007 Customized Reporting - SQL QueriesPreventing accidental NTFS data moves
      FSRM and NTFS Quotas in 2003 R2PowerShell Deleting NTFS Alternate Data StreamsNTFS links - reparse, symbolic, hard, junction
      IE Warnings when files are executedPowerShell Low-level keyboard hookCross-forest authentication and GP processing
      Deleting Invalid SMS 2003 Distribution PointsCross-forest authentication and site synchronizati...Determining AD attribute replication
      AD Security vs Distribution GroupsTroubleshooting cross-forest trust secure channels...RIS cross-domain access
      Large SMS Web Reports return Error 500Troubleshooting SMS 2003 MP and SLPRemotely determine physical memory
      VMware SDK with PowershellSpinning Excel Pie ChartPoke-Info PowerShell script
      Reading web content with PowerShellAutomated Cluster File Security and PurgingManaging printers at the command-line
      File System Filters and minifiltersOpsMgr 2007 SSRS Reports using SQL 2005 XMLAccess Based Enumeration in 2003 and MSCS
      Find VM snapshots in ESX/VCComparing MSCS/VMware/DFS File & PrintModifying Exchange mailbox permissions
      Nested 'for /f' catch-allPowerShell FindFirstFileW bypassing MAX_PATHRunning PowerSell Scripts from ASP.Net
      Binary <-> Hex String files with PowershellOpsMgr 2007 Current Performance InstancesImpersonating a user without passwords
      Running a process in the secure winlogon desktopShadow an XP Terminal Services sessionFind where a user is logged on from
      Active Directory _msdcs DNS zonesUnlocking XP/2003 without passwords2003 Cluster-enabled scheduled tasks
      Purging aged files from the filesystemFinding customised ADM templates in ADDomain local security groups for cross-forest secu...
      Account Management eventlog auditingVMware cluster/Virtual Center StatisticsRunning scheduled tasks as a non-administrator
      Audit Windows 2003 print server usageActive Directory DiagnosticsViewing NTFS information with nfi and diskedit
      Performance Tuning for 2003 File ServersChecking ESX/VC VMs for snapshotsShowing non-persistent devices in device manager
      Implementing an MSCS 2003 server clusterFinding users on a subnetWMI filter for subnet filtered Group Policy
      Testing DNS records for scavengingRefreshing Computer Account AD Group MembershipTesting Network Ports from Windows
      Using Recovery Console with RISPAE Boot.ini Switch for DEP or 4GB+ memoryUsing 32-bit COM objects on x64 platforms
      Active Directory Organizational Unit (OU) DesignTroubleshooting computer accounts in an Active Dir...260+ character MAX_PATH limitations in filenames
      Create or modify a security template for NTFS perm...Find where a user is connecting from through WMISDDL syntax in secedit security templates

      About Me

      I’ve worked in IT for over 20 years, and I know just about enough to realise that I don’t know very much.