Set Title on Mail Contact

I have several thousand mail contacts in my AD that i need to set a job title for.  I've tried both the Exchange Set-MailContact cmdlet and the Set-ADObject cmdlet, but neither seem to have a way to set the -Title field.  I need to populate the field with a static text string.
Who is Participating?
Will SzymkowskiConnect With a Mentor Senior Solution ArchitectCommented:
You would have to use the "set-contact" cmdlet. Use the following command below to accomplish this...

CSV File layout needs to have 2 columns Heading for Name and Heading for Title

Import-Module activedirectory
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin
$ContactList = Import-Csv "c:\[b]youCSVhere[/b]"
foreach ($Contact in $ContactList) {
Set-contact -Identity $Contact.Name -title $Contact.Title

Open in new window


ThinkPaperIT ConsultantCommented:
What is your exact code? Are you getting any errors?

You should be able to do it with set-mailcontact or set-contact
ThinkPaperConnect With a Mentor IT ConsultantCommented:
Correction - will is right, set-contact is what you need.
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Will SzymkowskiSenior Solution ArchitectCommented:
I tried to BOLD the $ContactList = Import-Csv "c:\yourCSVhere"

You don't need these in there. simply add your CSV file name between the quotes.
marrjAuthor Commented:
Thank you.  My problem was that I did not have both the Exchange snapin and the ActiveDirectory module present.  I had each of them present at different times, but never saw the Set-Contact cmdlet.

Instead of using an input file, I need to query a specific OU and replace the existing title for each contact in the OU.  For some reason, I'm not getting much help from the Get-Help Set-Contact cmdlet.  Do you have an example of what I'm trying to do?
Will SzymkowskiSenior Solution ArchitectCommented:
Just do the following...

Get-contact -filter * -searchbase "OU=testou,DC=yourdomain,DC=com" | select name | export-csv "c:\modifyContacts.csv"

Once you have this csv file you just have to add the Title heading in the csv file and put this csv file in the first script I posted.
marrjAuthor Commented:
Actually, what I ended up doing was piping the Get-Contact directly to a Where-Object filter then directly to the Set-Contact cmdlet.  Thanks for your help.  I will award you both some points.

Get-Contact -OrganizationalUnit "ou=Students,ou=Albuquerque,ou=Individuals,ou=SupplementalContacts,dc=contoso,dc=com" |
Where-Object {$_.Title -ne "Student Albuquerque"} |
Set-Contact -Title "Student Albuquerque"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.