Solved

Set "Department" field for over 200 Contacts using Powershell

Posted on 2012-03-13
2
1,893 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
[X]
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
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

756 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