Generically, here is what you will need to do. There are several tools on the internet to assist. We will attach a couple scripts as well. Proceed carefully as all the normal AD warning apply.
- Export your AD account names to a CSV file with Powershell.
- Open in Excel and add a column for the ipPhone field it its missing.
- Remove any row entries that do not apply. aka Service accounts etc.
- Enter the appropriate DN for each name
- Delete any unnecessary columns such as the DisplayName Column.
- Delete the header line with column names in it.
- Save as a CSV. example: c:\temp\ADUsersImport.csv
- Import the CSV to AD with Powershell.
SAMPLE Export Script (zero risk to anything.)
Change the highlighted text to your choice of export file name.
Get-ADUser -Filter {(Name -notlike "*(Administrator)")} -Properties SamAccountName,DisplayName,ipPhone| Select-Object SamAccountName,DisplayName,ipPhone | export-csv -path c:\temp\ADUsersExported.csv -NoTypeInformation -Encoding "UTF8"
SAMPLE Excel Spreadsheet
SAMPLE Import Script (Medium risk, make certain your data is clean)
Create a file with the following script named c:\temp\ipphoner.ps1
Import-Module ActiveDirectory
$CSVPath = "c:\temp\ADUsersImport.csv"
$csvData = Import-CSV $CSVPath -delimiter "," -Header ("sAMAccountName","IPPhone")
foreach ($line in $csvData )
{
$accountTable = @{
'sAMAccountName'= $line.sAMAccountName
'IPPhone'= $line.ipPhone
}
}
ForEach($line in $csvData)
{
$sAMAccountName = $line.sAMAccountName
$ipphone = $line.ipPhone
$Blank = ""
if([string]::isNullOrEmpty($sAMAccountName.description))
{ "modifying $($sAMAccountName) and adding $ipphone number "
$SETIPPHONE = GET-ADUSER $sAMAccountName -PROPERTIES ipphone
$SETIPPHONE.ipphone = $ipphone
Set-ADUser $sAMAccountName -Replace @{ipPhone=$ipphone} }
}
From the Windows Powershell prompt in a C:\Temp run the script.
.\ipphoner.ps1
This should update the iphhone field of all of the users in the CSV.
From the Windows Powershell prompt in a C:\Temp run the script.
.\ipphoner.ps1
This should update the iphhone field of all of the users in the CSV.