Solved

Powershell - Add "+45" to Phonenumbers in AD

Posted on 2013-06-13
6
304 Views
Last Modified: 2013-06-13
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!
0
Comment
Question by:Sum Wum
  • 2
  • 2
  • 2
6 Comments
 
LVL 37

Expert Comment

by:Neil Russell
ID: 39243679
Assuming that the phone number is stored in a variable called $phoneNumber.....

$phoneNumber = "+45 $phonenumber"

Will do it.
0
 
LVL 1

Author Comment

by:Sum Wum
ID: 39243683
Is there a way to do this quickly to all our users with powershell?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39243694
Get-ADUser -Filter * -Properties HomePhone | % {Set-ADUser $_ -HomePhone ("+45"+$_.HomePhone)}

Open in new window

0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39243695
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
 
LVL 37

Expert Comment

by:Neil Russell
ID: 39243707
Or using Quest QAD Commandlets....

Get-QADUser | % { Set-QADUser $_ -PhoneNumber "+45 $($_.phonenumber)" }
0
 
LVL 1

Author Closing Comment

by:Sum Wum
ID: 39243722
Couldn't ask for a better answer :)
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question