Quantcast
Channel: Software Communities : Popular Discussions - ActiveRoles
Viewing all articles
Browse latest Browse all 1277

How do I restructure and strip out extra characters in phone numbers for mass changes in AD

$
0
0

I'm looking to clean up our active directory by making all of the phone numbers the same format. Currently we have phone numbers in the following formats:

 

Phone Number                        IP Phone

(123) 456-789 EXT 6789          blank

(123)456-789 ext 6789            blank

(123) 456-7889 EXT 6789        blank

+123456789                                 blank

123-456-789                                balnk

(123) 456-789                             6789

 

What I'd like to do is find a way to use the quest add on for powershell (this is a 2003 environment) to strip out all the superfluous characters, be it -(s), or ((s)/)(s) or +(s) or whatnot and then change the number to a format I wish.  Preferably:

 

Phone Number                    IP Phone               Cell Phone

(123) 456-789                        1234                        (123) 456-8593

 

I need something that will look and see if there are 10 or 14 digits. If there are 10, I want this to strip all characters from them and reformat them as indicated above. If there are 14, I want the first 10 stripped and reformatted and the last 4 moved to the IP phone field. I also need all other phone fields to follow the stripping and reformatting of all 10 digits.  I've looked into this and while I can seem to find ways to replace individual phone numbers, I can't seem to find the coding advice to strip and replace digits in a format I want.  Any help would be deeply appreciated!


Viewing all articles
Browse latest Browse all 1277

Trending Articles