create AD contacts, Bulk create AD contacts - Active Directory PowerShell

Create AD contacts, Bulk create AD contacts - Active Directory PowerShell

Create AD contact

To create a single AD contact, use the below powershell command.

New-ADObject -Type "Contact" -Name "Displayname" -DisplayName "Displayname" -Description "Description" -Path "OU=Contacts,DC=domain,DC=com" -OtherAttributes @{ sn="surname";givenName="firstname";mail="externalemailaddress";mailNickname="sn.gn";targetAddress="SMTP:externalemailaddress";title="title";physicalDeliveryOfficeName="officelocation"}

Bulk create AD contacts

Create a csv file (contact_creation.csv) for the contacts with their external email address, user details description. The Column names as in the below snapshot . Open Active directory powershell as an administrator and run the below command to create contacts in bulk.


$users= Import-csv "contact_creation.csv"
foreach ($user in $users)
{
$extemail = $user.email
$name =  $user.name
$given = $user.gn
$sur = $user.sn
$pass = $user.passw
$des = $user.descrip
$nick = $user.sama
$ti = $user.titl
$addr = $user.physical
New-ADObject -Type "Contact" -Name $name -DisplayName $name -Description $des -Path "OU=Contacts,DC=domain,DC=com" -OtherAttributes @{ sn=$sur;givenName=$given;mail=$extemail;mailNickname=$nick;targetAddress="SMTP:$extemail";title=$ti;physicalDeliveryOfficeName=$addr}
}

Comments

Popular posts from this blog

Clearing Exchange online mailbox purge, dumpster folder

Add description to AD contact and bulk add description for contacts - Active Directory PowerShell