exchange 2010 newcontact command

I recently had the task to create a few hundred email contacts for exchange 2010 server. I then ran into a problem that made me scratch my head for little while. I had a user that was sending emails and the recipients were receiving winmail.dat files instead of the attachments that was actually sent with email. After some deductive reasoning I cam to realize that it was the contact that I made. The were all set to  USE MAPI rich text format.. which was causing the issue. I went back to my command to create the contacts and added the parameter -UsePreferMessageFormat ($false) which should translate to "Never" but it doesn't seem to work. I tried several ways to do it and every time it comes up <not set> which translates to Use default Settings........Does anyone have a way to get this actually work. Am I missing something?
changariAsked:
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.

Will SzymkowskiSenior Solution ArchitectCommented:
You are using the wrong switch for this. You need to use UseMapiRichTextFormat Never.

Set-MailContact -Identity -UseMapiRichTextFormat Never

Open in new window


Will.
0
changariAuthor Commented:
hi...

  that -UseMapiRichTextFormat Never is for the command Set-MailContact  
  I am using new-mailcontact ..  here is the command that I am using:

Import-Csv “d:\new7.csv” | ForEach {New-MailContact
-Name  ($_."LastName"+”, “+$_."FirstName"+” “+$_."MD" )      
-Alias ($_."LastName"+$_."FirstName")  
-Firstname $_.FirstName -LastName $_.LastName
-ExternalEmailAddress $_.ExternalEmailAddress
-OrganizationalUnit “xxxx.com/contacts” -UsePreferMessageFormat ($false)}

this reads my csv file and creates all the contact without a problem.. the only issue is that USE MAPI rich text format is defaulted and the  -UsePreferMessageFormat ($false) doesn't seem to work.. do I need to use another option or command with my command??
0
Will SzymkowskiSenior Solution ArchitectCommented:
All you need you do at the end of your script is add the | set-mailcontact -UseMapiRichTextFormat Never. Set-MailContact accepts pipeline in put so just add it at the end of your script.

Import-Csv “d:\new7.csv” | ForEach {New-MailContact 
 -Name  ($_."LastName"+”, “+$_."FirstName"+” “+$_."MD" )       
 -Alias ($_."LastName"+$_."FirstName")  
 -Firstname $_.FirstName -LastName $_.LastName 
 -ExternalEmailAddress $_.ExternalEmailAddress 
-OrganizationalUnit “xxxx.com/contacts” | set-mailcontact -UseMapiRichTextFormat Never}

Open in new window


If that does not work (which it should) try putting your Import-csv command in a variable and then use the ForEach command.

Will.
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
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

changariAuthor Commented:
Will,

   that was the ticket.. could you tell me if I had needed to use one of the variables from the new-contact command.. like -alias or -name from new-mailcontact for the set-mailcontact  -identity .. what i put.. luckily it uses the contact that i just created by default.
0
Will SzymkowskiSenior Solution ArchitectCommented:
When you use the "|" command it will use the user in the pipeline for the second command which is why then you use the Set-MailContact you do not need to use the "-Identity" switch.

The other way i was mentioning in my previous post is the following...
$MailContacts = Import-Csv “d:\new7.csv”
ForEach ($MailContact in $MailContacts)  {New-MailContact 
 -Name  ($_."LastName"+”, “+$_."FirstName"+” “+$_."MD" )       
 -Alias ($_."LastName"+$_."FirstName")  
 -Firstname $_.FirstName -LastName $_.LastName 
 -ExternalEmailAddress $_.ExternalEmailAddress 
-OrganizationalUnit “xxxx.com/contacts” | set-mailcontact -UseMapiRichTextFormat Never}

Open in new window


If you first script worked which it should have then you do not need to use a variable like i have illustrated.

Will.
0
changariAuthor Commented:
Thank you........................
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
Email Servers

From novice to tech pro — start learning today.