Importing user attributes with PowerShell
We have Exchange 2007 SP1, with AD 2003.In the past, I have successfully imported user attributes with a small script that I wrote;It filled in much of the basic info
#
# Created by Christian Wickham March 2009 - distribution encouraged, with this header
#
# Purpose:- Populate all Active Directory Objects with information
#
# where site is the name of the OU that is the City
# where state is the State or Locality
# where city is the text name of the city
#
# Assumptions:- OU structure is domain\users\state\city
#
$list = import-csv $args[0]
foreach ($i in $list)
{
$Container = "domain.com/Users/" + $i.State + "/" + $i.OU
write-Host "Processing" $Container
$person = Get-User -ResultSize Unlimited | Where-Object {$_.Identity -Match $Container }
foreach ($person in $person)
{
"Now Processing " + $person >> Log.txt
$CityCheck = $person.City
if ( $CityCheck.length -ge 1)
{
"Already has City of " + $CityCheck >> Log.txt
}
Else
{
Set-User $person -City $i.City
}
$StateCheck = $person.StateOrProvince
if ( $StateCheck.length -ge 1)
{
"Already has State of " + $StateCheck >> Log.txt
}
Else
{
Set-User $person -StateOrProvince $i.State
}
$CompanyCheck = $person.Company
if ( $CompanyCheck.length -ge 1)
{
"Already has Company of " + $CompanyCheck >> Log.txt
}
Else
{
Set-User $person -Company "My Company Name"
}
}
}
But, now we want to import more information in the same way.Some of the fields we want to import are not listed as available in set-user or set-mailbox, but the ARE listed as attributes in the Exchange 2007 Details Templates editor.Details Templates Name LDAP Name PurposePersonal-Title personalTitle Mr/Mrs/Miss/MsEmployee-Number employeeNumber HR reference employeeID employee IDBusiness-Category businessCategory We want to use this for "Division"Organisational-Unit-Name ou The OU structureGenerational-Qualifier generationQualifier Jr/Snr/IIISerial-Number serialNumber We want to use this for cubicle numberWe can update the Outlook form so that it displays these fields, but we cannot mass-populate these fields. Other than using ADSIedit or another tool to do this for all 5000 user accounts, is there a way for me to populate these attributes for users?Also, we would like to be able to display the Exchange Mailbox database in the Outlook details form - anyone know a way to do that?
December 21st, 2009 9:08am
You should take a look at ActiveRoles Management Shell for Active Directoryhttp://www.quest.com/powershell/activeroles-server.aspxThe editor PowerGUI is excellent!MCTS: Messaging | MCSE: S+M | Small Business Specialist
Free Windows Admin Tool Kit Click here and download it now
December 21st, 2009 10:00am
Besides using the Quest tools, you also have the option of using the AD cmdlets in Win7 RSAT if you install the ADGW service on at least one of your DCs.
December 21st, 2009 3:33pm
Thanks, this has helped, but I still cannot modify/import/use/read/write the following attributes either with PowerShell/Quest tool so that they can be shown after adding them to the Outlook details form with the Exchange Details template editor;Details Templates Name LDAP Name PurposePersonal-Title personalTitle Mr/Mrs/Miss/MsEmployee-Number employeeNumber HR reference employeeID employee IDBusiness-Category businessCategory We want to use this for "Division"Organisational-Unit-Name ou The OU structureGenerational-Qualifier generationQualifier Jr/Snr/IIISerial-Number serialNumber We want to use this for cubicle numberdoes anyone know a way to access these attributes?
Free Windows Admin Tool Kit Click here and download it now
January 11th, 2010 6:43am
Spoke too soon. I needed to do the following; set-qaduser "Wickham, Christian" -objectAttributes @{division=@("IT Services")} set-qaduser "Wickham, Christian" -objectAttributes @{employeeID=@("12345W56")} All fixed!
January 11th, 2010 7:19am