appending active directory through powershell

by Peeps3240 at 2012-08-31 08:55:41

Good morning, 2nd time poster short time reader

our active directory is not nearly as populated as it should be, ie missing phone numbers, job titles, departments…

i have a CVS file with all this information that i pulled in from various spreadsheets through VLOOKUP and it is as up to date as i can get it.

I have seen suggestions to use LADP to do this and i have seen instructions on how to create new users through a CSV import in LADP and PowerShell but i am worried that it wont just update but create new users of these entries with no passwords.

OU Name Type Description Modified Business Phone City Company Country/Region Department Display Name E-Mail Address Exchange Alias Exchange Mailbox Store First Name Instant Messaging Home Server Instant Messaging URL Job Title Last Name Office Phonetic Company Name Phonetic Department Phonetic Display Name Phonetic First Name Phonetic Last Name State User Logon Name Zip Code

these are all the various fields i pulled from active directory by doing the export command from each OU. to import these to update the various fields that are blank (noted by a #NA) is this possible without recreating each user in the OU?
by DonJ at 2012-08-31 11:11:08
That’s not much of a worry if you’re using the Quest AD cmdlets or the Microsoft AD cmdlets, as there are separate commands for creating and modifying (e.g., Set-QADUser or Se-ADUser vs. New-QADUser or New-ADUser). In other words, the “Set” commands change things, but have to be told which account to change, and can’t create a new account at all.

So it’s certainly possible to do what you want. I’m not suggesting using LDAP to do this, though.

Import-CSV your-file.csv | ForEach-Object {
Get-ADUser -filter { displayname -eq $.‘Display Name’ } | Set-ADUser -City $.City -Department $.Department (etc)

So this is just a snippet, and I’m using the Microsoft ActiveDirectory module (which is in the Win7 RSAT download, and can run against a Win2008R2 domain controller; it’ll run against a Win2003 or Win2008 domain controller if the DC is running the AD Management Gateway download). Notice how I used the $
.‘Display Name’ syntax to refer to a specific field from the CSV file. I did the same thing with $.City and $.Department, and you could extend that to refer to whatever other properties you want to update.

There are probably several other ways to accomplish this… so if any other readers here want to jump in with suggestions, please do!