Listing a Printer in the Active Directory
Share printer options have not been discussed yet. You can list shared printers in the AD by selecting the List in Directory context menu option for the printer. You can also enable the printer to be listed via the Sharing tab of the printer's properties and checking the List in the Directory box.
The printer object is created by default under the server that hosts the printer. To view the directory-listed printers, use the Active Directory Users and Computers MMC snap-in. From the View menu, select Users, Contacts, Groups, and Computers as Containers. You are now able to select a server, and the printer object is shown as a child object.
You can right-click this printer object and move it, open its print queue, and view some basic properties. You can manually create these entries in the AD by right-clicking a domain or organization unit and selecting New, Printer from the context menu. Enter the URL of the shared printer, such as \\server\printer share, and the printer object is created for you in that location.
The following script searches the AD and lists all printers that are published:
Const ADS_SCOPE_SUBTREE = 2 ' Check all arguments required have been passed If Wscript.Arguments.Count < 1 Then Wscript.Echo "Arguments <root DN> required. For example:" & vbCrLf & "cscript searchprinters.vbs dc=savilltech,dc=com" Wscript.Quit(0) End If strRootSearch = Wscript.Arguments(0) Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.CommandText = "Select printerName, serverName from " & " 'LDAP://" & strRootSearch & "' where objectClass= 'printQueue'" objCommand.Properties("Page Size") = 1000 objCommand.Properties("Timeout") = 30 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.Properties("Cache Results") = False Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF Wscript.Echo "Printer Name: " & objRecordSet.Fields ("printerName").Value Wscript.Echo "Server Name: " & objRecordSet.Fields ("serverName").Value objRecordSet.MoveNext Loop
To use the script, just execute via the cscript interpreter and paste the distinguished name that you want to search from. For example, if you want to search the entire virt.savilltech.net domain, the DN would be dc=virt,dc=savilltech,dc=net. If you just wanted to search within the Justice League organizational unit (OU), use ou=justice league,dc=virt,dc=savilltech,dc=net. For example:
C:\Tools>cscript searchprinters.vbs dc=virt,dc=savilltech,dc=net Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved. Printer Name: HP Officejet Pro L7680 All-in-one Lab A Server Name: savdaldc01.virt.savilltech.net Printer Name: HP Photosmart C5100 series Server Name: savdaldc01.virt.savilltech.net
Why publish printers in the AD? It makes it easier for administrators to find printers for management purposes, but most importantly, it helps users find them.
In this tutorial:
- Windows Server File System and Print Management
- File System Types and Management
- New Technology File System (NTFS)
- New NTFS Features in Windows Server 2008
- Formatting and Managing File Systems
- Converting File Systems
- File Management
- File Permissions
- Shares
- NTFS Quotas
- Encrypted File System (EFS)
- Shadow Copy Feature
- File Server Resource Manager
- File Server Resource Manager Options
- Reporting
- Quotas
- File Screening
- Exporting and Importing File Screens and Quotas
- Print Management
- Print Management MMC
- Printer Properties
- Listing a Printer in the Active Directory
- Connecting Users to Network Printers
- Deploying Printers
- Allowing Nonadministrators/Power Users to Install Printers
- Migrating a Printer
- Automatic Network Print Addition
- Print Server Configuration
- Customizing Views of Information