Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Set "Department" field for over 200 Contacts using Powershell

Posted on 2012-03-13
2
1,863 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

791 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