Republish printers easily on a print server to Active Directory.

Republish printers easily on a print server to Active Directory.

  • Comments 1
  • Likes

Printers can get pruned from the directory for many reasons.  The way it is supposed to work is if the printer is stale then a DC will remove the print queue object from the directory after trying to contact it 3 times at 8 hour intervals (default).  This also means that if a DC can't net view the print server for a 24 hour period it could potentially prune the print queue objects too.  This can happen if one of your domain controllers are in a "bad" state where its online but not functioning as expected. 

So what can you do once the print queue objects have been removed?  Well to easily republish them you can create a simple script like below. You can then save this as a vbs and then use it to republish the printers in the directory.

 

If WScript.Arguments.Count <> 1 then
        strPC = GetPC()
Else
        strPC = wscript.arguments(0)

        end if

Set objWMIService = GetObject("winmgmts:\\" & strPC & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)
For Each objItem in colItems
    Wscript.Echo "ShareName: " & objItem.ShareName
     objItem.Published = False
      objItem.Put_
      Wscript.Echo "Published: " & objItem.Published
     objItem.Published = True
      objItem.Put_
      Wscript.Echo "Published: " & objItem.Published
Next

function GetPC()
        GetPC = InputBox ("What Server would you like republish the printers on?", "Servername")
End function

 

To work around this you could do a number of things:

1) Fix the network connectivity issue

a) Find out what Dc is not working as expected and resolve.

2) Disable the spooler service on your DCs

a) Could have lots of stale printers to manually clean up if you have printers in flux in your environment

3) Disable pruning via GPO

a) Set the Directory Pruning Interval value to Never via GPO

b) There will be stale printers in the directory and they will need to be manually cleaned up.

4) You can allow the printers to be pruned and set the Check Published State policy for specific (or all) print servers in the domain. This policy causes the    spooler on a print server to periodically verify that its published printers exist in Active Directory. By default, the Spooler service verifies the state of published printers only when it is started.

a) Because the widespread use of this policy on many computers in the domain (that are constantly checking the publication status of their PrintQueue objects in Active Directory) can adversely affect network performance. Microsoft recommends that you set this policy only on the main production print servers.

 

If you want to know more about how printers are published and pruned this is a thorough article on the subject.

Comments
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment