active directory script

Need help finding a script to add +1 to the telephone number in the general tab under an active directory user object. is this possible? I need to make this change to over 500 user objects in active directory. thanks.

this question is worth 500 points.
Who is Participating?
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.

gc c:\userlist.txt | % {
$username = $_
$oldphone = GetADUser -Identity $username -Properties OfficePhone
$nuphone = "1" + $_.OfficePhone
Set-ADUser -Identity $username -OfficePhone $nuphone -whatif

Open in new window

Something like above should work (untested)
Jim P.Commented:
P would look at using the  dsmod user.

You can do a dsquery to get the right person.

It will be something like
DSQUERY USER -samid doej| DSMOD user -phone1 8005551212

Open in new window


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

You can use this Vbscript
Set ArrayUser = GetObject  ("LDAP://OU=test,DC=N2NetworkSolutions,DC=com")
ArrayUser.filter=Array ("user")
For Each objUser In ArrayUser
objUser.get "officePhone", phone
objUser.Put "officephone", phone

for testing you can begin with a small test OU, then launch at large scale. The target can be configurated on the GetObject parameters.

mildogzAuthor Commented:
hey thanks folks. I have not gotten around to testing yet. we had some hold up and I was away for two weeks. so I will try some of this scripts and let you know. I apologies for the delay here. thanks again.
mildogzAuthor Commented:
thanks guys. We end up just doing it manually. but will keep the info in case i need for future reference.
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
Microsoft Server OS

From novice to tech pro — start learning today.

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.