Configuring Printer Locations

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

Printer location tracking requires printer locations to reflect the actual physical location of the printer in question. If a printer moves from one building to another, the location attribute must be changed to reflect this move. If the naming scheme is changed, printer locations must be changed accordingly. If a building is renamed, printer locations must, again, be modified to reflect the change.

You can modify printer locations by binding to the printer object in Active Directory and then changing the Location attribute. This is useful if you need to change the location for an entire group of printers, such as all the printers in the Finance organizational unit.

Scripting Steps

You can use printer location configuration in several ways:

  • Configuring initial printer locations.
  • Updating a set of printer locations.

Configuring initial printer locations

Listing 13.18 contains a script that configures printer locations. To carry out this task, the script must perform the following steps:

  1. Use a GetObject call to bind to the Finance organizational unit in Active Directory.
  2. Set the Filter property to "printQueue" to ensure that only printer objects are returned.

    This prevents you from inadvertently changing the location for a computer or a user account.

  3. For each printer in the Finance organizational unit (OU), use the Put_ method to specify the location. This method requires two parameters:
    • Location The attribute to be changed.
    • USA/Redmond/Finance Building The new value for the attribute.
  4. Use the SetInfo method to apply the changes to each printer object.

Listing 13.18   Configuring Printer Locations

1 2 3 4 5 6 
Set objOU = GetObject("LDAP://OU = Finance, DC = fabrikam, DC = com") objOU.Filter = Array("printQueue") For Each objPrintQueue In objOU     objPrintQueue.Put "Location" , "USA/Redmond/Finance Building"     objPrintQueue.SetInfo Next

Updating a set of printer locations

If you are configuring the location of a single printer only, there is no need to write a script; it is probably faster and easier to make this change using the graphical user interface. In other cases, however, you might need to make a similar change to a large number of printers. In those situations, a script will prove faster and more efficient.

For example, suppose your initial naming scheme includes only the building number and the floor number (such as Building 37/Floor 2). As your organization expands, a branch office might be opened in a new city. In that case, you should modify your naming scheme to reflect the fact that different buildings are in different cities.

Listing 13.19 contains a script that updates printer locations. To carry out this task, the script must perform the following steps:

  1. Use a GetObject call to bind to the Finance organizational unit in Active Directory.
  2. Set the Filter property to "printQueue" to ensure that only printer objects are returned.

    This prevents you from inadvertently changing the location for a computer or user account.

  3. Set the variable strNewLocation to Redmond/ plus the current printer location. For example, if the printer is currently in Building 37/Room 4, the new location will be Redmond/Building 37/Room 4.
  4. For each printer in the Finance OU, use the Put_ method to specify the location. This method requires two parameters:
    • Location The attribute to be changed.
    • StrNewLocation The new value for the attribute.
  5. Use the SetInfo method to apply the changes to each printer object.

Listing 13.19   Updating Printer Locations

1 2 3 4 5 6 7 
Set objOU = GetObject("LDAP://OU=Finance, DC=fabrikam, DC=com") objOU.Filter = Array("printQueue") For Each objPrintQueue In objOU     strNewLocation = "Redmond/" & objPrintQueue.Location     objPrintQueue.Put "Location" , strNewLocation     objPrintQueue.SetInfo Next

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net