Mart's example is an excellent way to illustrate the concept of reading AD and acting upon the data. In practice, however, coding your script around people or places is not good practice.. (I'm speaking in general terms, and not specifically about the example here.)

My point is - if a printer changes, you need to modify your script. If you add or remove a location, you need to significantly modify your script. What if a location has two (or more) printers? Yes, you have to modify your script for that site.

Kix supports the use of INI files, which can be used like simple databases. You can create an INI file like this:
 Code:
[SITE1]
Printers=\\server\printer
Default=\\server\printer
[SITE2]Printers=\\server2\printer1;\\server2\printer2
Default=\\server2\printer2

Each site has its own section, listing the printer(s) to map, and the default printer. The sections "[SITEx]" are named exactly the same as the AD sites you're referencing. Printers are listed, separated with semi-colons when there's more than one.

The code that would replace the Select/EndSelect statements would look like this:
 Code:
; read the list of printers, and the default printer
$Printers = ReadProfileString('.\printers.ini', $Office, 'Printers')
$Default = ReadProfileString('.\printers.ini', $Office, 'Default')

; continue only if printers are defined for this site
If $Printers
  ; map all defined printers
  For Each $Printer in Split($Printers, ';')
    $rc = AddPrinterConnection($Printer)
  Next
  ; set one as a default
  $rc = SetDefaultPrinter($Default)
EndIf

Now, if things change, all you do is add or edit the entries in the INI file, not your script. The more times you put your hands in your script, the more chances you have for failure. Keep the script logic simple, even if it means adding some "complexity" of an external file to manage site or user-specific data. It will be well worth it in the long run.

NOTE: You may need to specify the full path to the INI file, or use @SCRIPTDIR\printers.ini instead.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D