Search This Blog

Thursday, September 1, 2011

Export/Import Contacts

Exporting an importing contacts has become easy since Powershell was introduced. In the old days we used tools as CSVDE or LDIFDE to export, import contact information. This article describes both ways.

CSVDE

Export
[Code]
CSVDE -f C:\Mailcontacts.csv -r ObjectClass=Contact -l Objectclass,DisplayName,GivenName,SN,Mail
[/Code]
Import
[Code]
CSVDE -i -f C:\Mailcontacts.csv
[/code]

LDIFDE

Export
[Code]
LDIFDE -f C:\MailContacts.ldf -r ("Objectclass=Contact") -l Objectclass,DisplayName,GivenName,SN,Mail
[/Code]
Import
[Code]
LDIFDE -i -f C:\Mailcontacts.ldf
[/Code]

Powershell
Get-contact | select-object Name, DisplayName, FirstName; LastName; WindowsEmailAddress | Export-csv C:\Mailcontacts.csv

$Contacts = import-csv C:\Mailcontacts.csv
Foreach ($_.Name in $Contacts) {New-contact -Name $_.Name -DisplayName $_DisplayName -FirstName $_FisrName -LastName $_LastName -Externaladdress $_.WindowsEmailAddress -Ou "OU=Contacts,DC=Domain,DC=Suffix,"}

You can of course combine  these tools to export for example contacts out of Windows Server 2003 and import them in Windows Server 2008. Just remember that you need to modify the CSV tables to match the variables in the powershell Cmdlet.

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete