Bulk Update User Phone Numbers in Active Directory
Keeping user contact information up to date in Active Directory is essential for effective communication within an organization. This PowerShell script allows administrators to bulk update the phone numbers of user accounts based on a CSV file. With this script, you can ensure that all user information is accurate and current.
At ServerEngine, we provide intuitive tools to enhance your IT management. Visit [ServerEngine](https://serverengine.co) to discover more solutions tailored for efficiency.
### Step 1: Import the Active Directory Module
Before running the script, ensure that the Active Directory module is loaded in your PowerShell session. This module contains the necessary cmdlets for managing Active Directory.
“`powershell
Import-Module ActiveDirectory
### Step 2: Prepare Your CSV File
Create a CSV file with the required user information. Each row should contain the username (SamAccountName) and the new phone number you wish to set.
Example `phone_updates.csv`:
“`
UserName,PhoneNumber
jdoe,123-456-7890
jsmith,987-654-3210
“`
### Step 3: Define the Function to Update User Phone Numbers
Next, create a function named `Update-ADUserPhoneNumbers` that reads from the CSV file and updates the phone numbers for each user.
“`powershell
function Update-ADUserPhoneNumbers { param ( [string]$csvPath ) $users = Import-Csv -Path $csvPath foreach ($user in $users) { $username = $user.UserName $phoneNumber = $user.PhoneNumber try { Set-ADUser -Identity $username -TelephoneNumber $phoneNumber Write-Host "Successfully updated phone number for user: $username" } catch { Write-Host "ERROR: Could not update phone number for user: $username. Error: $_" } } }
### Step 4: Execute the Phone Update Function
Now, you can execute the function to update the phone numbers as specified in your CSV file.
“`powershell
Update-ADUserPhoneNumbers -csvPath "C:\Path\To\Your\phone_updates.csv"
### Conclusion
This PowerShell script significantly simplifies the process of updating user phone numbers in Active Directory, ensuring that your organizations contact information remains accurate. For more powerful tools to support your server management needs, check out [ServerEngine](https://serverengine.co).