Solved

Powershell - Add "+45" to Phonenumbers in AD

Posted on 2013-06-13
6
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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