Powershell - Add "+45" to Phonenumbers in AD

Hi,

I want to add "+45" to the existing phonenumber on all our users in AD, so a users phone number changes to "+45 #and their existing number#".

How can this be done with powershell?

Thanks in advance!
LVL 1
Sum WumAsked:
Who is Participating?
 
Meir RivkinConnect With a Mentor Full stack Software EngineerCommented:
if u need users under specific OU use -SearchBase, for eample:
Get-ADUser -Filter * -SearchBase 'OU=HumanResources,OU=UserAccounts,DC=FABRIKAM,DC=COM'  -Properties HomePhone | % {Set-ADUser $_ -HomePhone ("+45"+$_.HomePhone)}

Open in new window

0
 
Neil RussellTechnical Development LeadCommented:
Assuming that the phone number is stored in a variable called $phoneNumber.....

$phoneNumber = "+45 $phonenumber"

Will do it.
0
 
Sum WumAuthor Commented:
Is there a way to do this quickly to all our users with powershell?
0
Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

 
Meir RivkinFull stack Software EngineerCommented:
Get-ADUser -Filter * -Properties HomePhone | % {Set-ADUser $_ -HomePhone ("+45"+$_.HomePhone)}

Open in new window

0
 
Neil RussellTechnical Development LeadCommented:
Or using Quest QAD Commandlets....

Get-QADUser | % { Set-QADUser $_ -PhoneNumber "+45 $($_.phonenumber)" }
0
 
Sum WumAuthor Commented:
Couldn't ask for a better answer :)
0
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.

All Courses

From novice to tech pro — start learning today.