Link to home
Start Free TrialLog in
Avatar of Michael Leonard
Michael LeonardFlag for United States of America

asked on

need a powershell script to modify the telephoneNumber field

can someone provide a powershell or quest AD cmdlets script that will remove a leading "space" character from the 'telephoneNumber" field

basically, we have a few thousands users in an OU, and some of them have been entered with a "space" before the +1- number
so for example, instead of [+1-123-456-7890]  the number is entered [ +1-123-456-7890]

would like the script to run through and look for any leading spaces in that telephoneNumber field and remove it, if it finds the space.

many thanks!

S.
Avatar of SubSun
SubSun
Flag of India image

Try this...
Get-qaduser -SearchRoot Test.com/HQ/Users -SizeLimit 0 | 
%{If ($_.Telephonenumber -ne $null){Set-QADUser $_ -PhoneNumber $($_.Telephonenumber -replace "\s{1}")}}

Open in new window

Avatar of Michael Leonard

ASKER

Thx subsan, works great,  one issue is that we also have european numbers in this format that have spaces that we dont want to impact / change:  +32 9 239 8085
can the script be adjusted to only look at the space in the first position of the number?

many thanks!

S.
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
excellent. many thanks!

S.