script to create external contact on exchange 2013

hello,

we have a job every night turn on our active directory to create contacts without activate exchange contact.

so i need a script i can use with scheduled task to go in specific OU (included all sub OU) and activate exchange contact for all contact.

thanks for help
cawasakiAsked:
Who is Participating?
 
Todd NelsonSystems EngineerCommented:
This will most likely get you what you want...

Get-Contact -OrganizationalUnit "OU=TEST,OU=Contacts,DC=contoso,DC=com" | foreach { Enable-MailContact -Identity $_ -Alias ($_.firstName+"."+$_.lastName) -ExternalEmailAddress $_.WindowsEmailAddress.toString() -PrimarySmtpAddress $_.WindowsEmailAddress.toString() }

Open in new window


Setting the 'PrimarySmtpAddress' parameter will automatically set the 'EmailAddressPolicyEnabled' parameter to "false".  Therefore the proxyAddresses do not get added.  And yes, the 'ExternalEmailAddress' parameter is required.

0
 
Todd NelsonSystems EngineerCommented:
At a minimum, for an existing AD contact to be usable in Exchange, you will need to add mailNickname, targetAddress, proxyAddress.  Maybe you can add values for those attributes during the process that creates the AD contacts.
0
 
cawasakiAuthor Commented:
hello
the contact attribute on AD contain all this attribute.
0
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

 
cawasakiAuthor Commented:
so any help?
0
 
Todd NelsonSystems EngineerCommented:
Maybe not understanding your question.  With values set for those specific attributes stated, the contacts will be available in Exchange 2013.  Maybe you can provide some screenshots.
0
 
cawasakiAuthor Commented:
i have a partner push this contact in my Active directory, it can only create contact on AD side, and i need to enable contact on exchange.

waht i need is the script or command line to get all contact on the OU and enable exchange contact
0
 
Todd NelsonSystems EngineerCommented:
You can use the following command in the Exchange Management Shell...

0
 
cawasakiAuthor Commented:
hello,

found a solution for my need:

Get-contact -OrganizationalUnit "OU=TEST,OU=Contacts,DC=contoso,DC=com" -RecipientTypeDetails Contact| foreach { enable-mailcontact -Identity $_ -alias ($_.firstName+"."+$_.lastName) -ExternalEmailAddress $_.WindowsEmailAddress.toString() 

Open in new window


this is activate all contacts on my exchange, but on proxy address, it add an alias with my own domain like user@contoso.com.

its possiblle to add any think to the command to not use my own domain for external contact?
0
 
Todd NelsonSystems EngineerCommented:
You might need to append your script to disabled the application of the email address policies...

Set-MailContact -EmailAddressPolicyEnabled $false

Open in new window



Then, you might need a script like this to remove the additional addresses...

$Contacts = Get-MailContact -Result Unlimited
$Contacts | foreach{
	for ($i=0;$i -lt $_.EmailAddresses.Count; $i++)
	{
		$address = $_.EmailAddresses[$i]
		if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like "*EmailDomainToRemove.com" )
		{
			Write-host($address.AddressString.ToString() | out-file C:\AddressesRemoved.txt -append )
			$_.EmailAddresses.RemoveAt($i)
			$i--
		}
	}
	Set-MailContact -Identity $_.Identity -EmailAddresses $_.EmailAddresses
}

Open in new window

0
 
cawasakiAuthor Commented:
Hello,

yes this is what i constat, the problem is my default address list.

so i need a solution like you said for "-EmailAddressPolicyEnabled $false" when i use my script with enable contact, i think its possible when enable contact to skip adress policies?
0
 
cawasakiAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.