These scripts were created in order to bulk update the ipPhone field in Active Directory for compatability with Cisco IP Telephones.

The telephoneNumber field in Active Directory had been historically filled out with numbers such as (555) 555-1234. The Cisco phone system we purchased first required the numbers to be stored as a string with no special characters (eg: 5555551234) - thus updateIPphone-10digit was created.

Later, our vendor required that the ipPhone field be extension only, (eg: 5555). Thus, updateIPphone-extension was made.

We then ran into a scenario wherein the number we stored in active directory wasn't necessarily a number that we needed an extension for (for example, an object in AD with a cell phone number instead of company number), so script updateIPphone-combined was created with logic that checked Area Code and Prefix before determining whether to populate it with the last 4 digits, or with all 10 digits minus special characters.

This script will update the ipPhone field so that it is the same as the telephoneNumber field, minus special characters (eg: hyphens, parenthesis, etc)

This script will update the ipPhone field so that it is the same as the last 4 digits of the telephoneNumber field.

This script will update the ipPhone field so that if telephoneNumber matches your area code and prefix (eg: (555) 555) that it will update ipPhone with the last 4 digits only (eg: 1234), and if it doesn't match our area code and prefix, it will update the ipPhone field with the entire 10 digit string minus special characters (eg: 5555551234). You must edit the script and replace "AREACODE" with your area code, and "PREFIX" with your prefix.