Creating Mail Contacts with Power Shell
The set-mailcontact parameters only allow you to set mail enabled attributes for AD attributes such as title and company you need to use the set-contact cmdlet.James Chong MCITP | EA | EMA; MCSE | M+, S+ Security+, Project+, ITIL msexchangetips.blogspot.com
March 15th, 2012 8:42pm

I've began receiving a monthly CSV file that is a dump of the GAL from another company we own. They are totally autonomous and there is no chance of any AD integration between the two organizations, so these records are being imported into our AD as mail contacts. Here is the powershell script I created to do this: $ContactList = Import-Csv c:\import.csv foreach($contact in $ContactList) { $name=$contact.displayName + " - EX" New-MailContact -Name $name -ExternalEmailAddress $contact.mail -DisplayName $name -Firstname $contact.givenName -Initials $contact.initials -Lastname $contact.sn -OrganizationalUnit "EXContacts" } This seems to work well enough, just tested and it creates the contacts. However, some of the fields in the source CSV file (in particular, title, company, etc) don't seem to exist in the New- MailContact function. Am I missing something, or is there a way to add these at creation, or after the fact via another commandlet? Any help is appreciated.
Free Windows Admin Tool Kit Click here and download it now
March 17th, 2012 1:36pm

The set-mailcontact parameters only allow you to set mail enabled attributes for AD attributes such as title and company you need to use the set-contact cmdlet.James Chong MCITP | EA | EMA; MCSE | M+, S+ Security+, Project+, ITIL msexchangetips.blogspot.com
March 17th, 2012 1:47pm

Thanks, that worked perfect. Appreciate the help!
Free Windows Admin Tool Kit Click here and download it now
March 17th, 2012 4:23pm

Final script if it helps anyone else out: # Import Contacts # By David # 3/14/2012 $ContactList = Import-Csv c:\import.csv foreach($contact in $ContactList) { $name=$contact.displayName + " - EX" $alias=$contact.givenName + $contact.initials + $contact.sn + "EX" $alias = $alias.Replace(" ", "") # get rid of any spaces since they aren't allowed in alias $alias = $alias.Replace(",", "") # get rid of any commas since they aren't allowed in alias $alias = $alias.Replace("(", "") # get rid of any parens since they aren't allowed in alias $alias = $alias.Replace(")", "") # get rid of any parens since they aren't allowed in alias New-MailContact -Name $name -alias $alias -ExternalEmailAddress $contact.mail -DisplayName $name -Firstname $contact.givenName -Initials $contact.initials -Lastname $contact.sn -OrganizationalUnit "EXContacts" set-contact -identity $alias -title $contact.title -notes $contact.description -phone $contact.telephoneNumber -department $contact.department -company $contact.company -office $contact.physicalDeliveryOfficeName }
March 17th, 2012 4:25pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics