Solved

Set "Department" field for over 200 Contacts using Powershell

Posted on 2012-03-13
2
1,783 Views
Last Modified: 2012-03-14
Experts-

I am currently running a powershell command to import a bulk list of contacts:

=============

$CSV=Import-Csv "C:\contacts\powershellContacts.csv"
foreach ($line in $CSV)
{
New-MailContact -Name $line.displayName -DisplayName $line.displayName -ExternalEmailAddress $line.emailAddress -LastName $line.sn -FirstName $line.givenName -Alias $line.alias1 -OrganizationalUnit "Finance"
}

=============

However, it does not set all the proper fields.

Is there a way to modify the "Department" field for all these contacts? I tried adding "-Department" but it did not work as it is not a valid argument. I also tried selecting the contacts in Active Directory to see if I could modify it through there, but there were no options to do this. I have over 200 contacts. Is there an easy way to do this?
0
Comment
Question by:ThinkPaper
2 Comments
 
LVL 2

Accepted Solution

by:
SieQ earned 500 total points
ID: 37717400
Becuase it's more AD property you should use
set-contact $line.displayName -department "DeptName"

same as get/set-mailbox and get/set-user, some attributes can be set with set-mailbox and some with set-user
0
 
LVL 16

Author Closing Comment

by:ThinkPaper
ID: 37720456
THANKS! You are a life saver! I kept looking at New-MailContact and Set-MailContact, and did not even think to look to see if there was a "Set-Contact". That worked perfectly. Thanks!!

$CSV=Import-Csv "C:\contacts\Contacts.csv"
foreach ($line in $CSV)
{
$myPath = "blah.com/Contacts/Finance/" + $line.displayName

Set-Contact -Identity $myPath -Department "Finance"

}
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
how to add IIS SMTP to handle application/Scanner relays into office 365.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now