Create Address List (Perl)

This code can be found in Chapter 5 of Exchange Server Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the Perl code from this site.

# This script was originally published in the Exchange Cookbook,
# (http://www.exchangebookcook.com). Written by Paul Robichaux, 
# Missy Koslosky, and Devin Ganger. Redistributed with permission 
# of the publisher, O'Reilly & Associates.

# This code creates a new top-level address list
# ------ SCRIPT CONFIGURATION ------

use Win32::OLE;

$strDCName = '<serverName>';
# e.g. "batman"	
$strContainer = '/CN=All Address Lists,CN=Address Lists Container,CN=<orgName>,CN=Microsoft Exchange,CN=Services,CN=Configuration,<domain>';
$strALName = '<newName>';
# e.g. Toledo Employees"
# ------ END CONFIGURATION ---------
$what = 'LDAP://' . $strDCName . $strContainer;
$objContainer = Win32::OLE->GetObject($what);
$objAddrList = $objContainer->Create('AddressBookContainer', 'cn=' . $strALName);
$objAddrList->Put('displayName', $strALName);
$objAddrList->Put('Instancetype', '4');
$objAddrList->Put('objectCategory', 'CN=Address-Book-Container,CN=Schema,CN=Configuration,DC=robichaux,DC=net');
$objAddrList->Put('PurportedSearch', '(&(mailNickname=*)(objectClass=user))');
$objAddrList->SetInfo();

This code has been viewed 1012 times.

New from the creators of TechTasks.com: StatSheet.com