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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
cawasakiAuthor Commented:
so any help?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cawasakiAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.