Thursday, March 13, 2014

PowerShell Script : KB2692134 - Copy Outlook Contact's Other field data to other contact fields using PowerShell.

 

Quote of the Day: All our dreams can come true – if we have the courage to pursue them. – Walt Disney

 

If you remember, few days ago I have uploaded a script to which access “Outlook” contact’s using PowerShell and I also wrote a blog article on it.

In that post, I have also mention that, Why I need this kind of script to retrieve contacts from the outlook, you may know the answer in my coming blog posts.

 

Now please let me describe to you why I have written that script.

 

If you are an “Exchange 2007, Exchange 2010” administrator, then you must be aware of Microsoft knowledge base article number “KB 2692134”.

 

In “KB2692134” knowledge base Microsoft has mention this.

 

KB2692134

Consider the following scenario:

·         Your mailbox is hosted on a server that is running Microsoft Exchange Server 2007 or Microsoft Exchange Server 2010.

·         You create a new contact in Microsoft Office Outlook 2007.

·         Under Phone numbers, you type a telephone number in the Home and Mobile fields.

·         You click Business, click Other, and then type a telephone number in the Other field.

·         You synchronize your mobile device that uses Microsoft Exchange ActiveSync over-the-air.

In this scenario, the information in the Home and Mobile fields is synchronized as expected. However, the information in theOther field does not synchronize as expected

Cause

This issue occurs because the Exchange ActiveSync protocol does not support synchronizing some contact information.

More Information

The behaviour that is mentioned in the "Symptoms" section can occur if you change the field name for any of the default fields. For example, if you click Business, Home, Business FAX, or Mobile, and then change the field name to Other, the data is not synchronized as expected.

The following table summarizes the field names that will synchronize and that will not synchronize as expected:

Field names that will synchronize

Field names that will not synchronize

Company

Assistant

Pager

Callback

Business

Car

Business 2

ISDN

Business Fax

Other Fax

Home

Primary

Home 2

Other

Home Fax

Radio

Mobile

Telex

 

 

 

In nutshell, if you are running “Microsoft Exchange Server 2007” or “Microsoft Exchange Server 2012” , and if some of you user has telephone  number on there “Other” field of  Outlook contacts, they can’t see them on any device  which they has configure their email account using Active Sync.

 

Note: I am not sure, but I do believe “office 365 Exchange Online has a same issue too. {I tested this on iPhone + Office 365}”

 

Here comes the problem, if that user is your BOSS or Manager and he/she has an important telephone numbers in his/her Outlook contact’s  “other” , now what you will do? Show him/her the KB article? Do you think that going to work?

No! I am right, you have to do that.

 

If you check the above table, in the table “Field Names that will synchronize” we have two fields which normally most of the person won’t use, “Business 2” and “Home 2”.

What if? If we move the data from “Other” field to “Business 2” or “Home 2”.field.

Sound interesting? Yes it is. You like it, yes? Cool, now go and write a script to do it.  ;o) 

 

Don’t worry, I already done that for you too. You can download the script from the below link:

Download link : http://gallery.technet.microsoft.com/Copy-Other-field-data-of-e35891a0

How this script work.

 

This script run on a user’s laptop, it use the Outlook’s “Outlook. Application” as com object and bind it with PowerShell and do the further task.

How to use it.

 

Note: Before running it on a user’s laptop, make sure you backup his contact’s first.

I have tested this script on “windows 8.1” and with “Outlook 2013” installed and I do hope it worked well on “Windows 7” and with “Outlook 2010”.

In the screenshots, the script name is different, don’t worry, I have just renamed it after taking the screenshot.

 

You can see, in below screenshot that contact “Gobind”,”Aman” and Romy” has a data in there “Other Phone” field.

13-03-2014 17-04-17

Figure 1 Screenshot of  Outlook contacts, you can, see some has phone numbers in “Other Phone” , and some in “Business 2” and some in “Home 2”

 

Run the script, and you can see that, it will show you the list of all contacts, with their “other TelephoneNumber”, “FullName” , “First Name” and “Email Address field”.

13-03-2014 17-08-53

Figure 2 Script run, but no change has made, because “Edit-OtherOutlookContact” function is commented in the original script.”

 

Now open the script and uncomment the below “Edit-OtherOutlookCOntact” function and save the script file.

 

13-03-2014 17-10-37

Figure 3 Screenshot of the commented function

To

13-03-2014 17-11-33

Figure 4 Screenshot of the Function after un-commenting. {# removed from front of it}

 

Now run the script again, you can see, it done some changes on “Aman”, “Romy”, and “Gobind” contact names.

 

13-03-2014 17-13-16

Figure 5 , we run the script again, and you can see, that it is showing that, it is changing the comments and it also opened a text file, which has the name of the contacts which we have just changed.

 

When this script run, it saved the list of all users name those other fields are moved to either “Home 2” or “Business 2”.  This files open automatically when It changes anything, by default this file saves at:  "$env:APPDATA\ChangedContactList.txt"   , and the name of the file is ChangedContactList.txt”.

 

Let’s check our Outlook contacts.

You can see that. All or number from “Other” fields are either move to “Home 2” or Business 2”.

 

13-03-2014 17-27-03

Figure 6 Changes are made by the script. You can see that,

 

Remember: before moving number to “Home 2” or “Business 2”, this script check for existing data in any of these contact fields.

In-case if data is exists in “Home 2”, it will move the “Other” field data to “Business 2”, if “Business 2” has some data, then it try to save the data to “Home 2” fields.

 

What if? Home 2 and Business 2 both have the data.

In that case, it will create a text file named NotChangedContactList.txt" and open it for you , so that you can decide what to do next.

13-03-2014 17-29-03

Figure 7 If “Home 2” and “Business 2” fields are not blank, it will save the name of those contacts which has data in there “Other” filed and save it in to a file.

 

This file saves in the same location: "$env:APPDATA\NotChangedContactList.txt"

 

If you want to retain the data of the “Other” field. Then delete or uncomment the below scipt code in the script.

 

$name.OtherTelephoneNumber = $null ;

 

That’s all for toady and happy scripting.

 

clip_image016Download link : http://gallery.technet.microsoft.com/Copy-Other-field-data-of-e35891a0

 

Thanks for reading this post, I hope you will find it useful.

 

clip_image018

Regards

Aman Dhally

 

 

If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel for PowerShell video tutorials. You can download all of my scripts from “Microsoft TechNet Gallery”.

 

 

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.