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?
 
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
 
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
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

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