1

Is there a PowerShell script or some tool to help me remove additional Contact information from all/certain users in Active Directory.

There is First name, Last name and Display name which is fine but then, there is Job title, Department, Office, Office phone, Mobile phone, fax number, Street address, city State or province, ZIP or postal code and Country or region.

I would like to delete all the information but First name, Last name, and Display name.

We have a lot of users in tenant and those fields are filled and very outdated. And since there are over thousand users it would take really long time to go one by one and remove it manually.

Would be glad for any help.

closed as off-topic by Robert Lindgren, Gaurravs, Asad Refai, moe, Mohamed El-Qassas MVP Dec 21 '17 at 11:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions not specific to SharePoint are off-topic here, but can be asked on Stack Overflow." – Robert Lindgren, Gaurravs, Asad Refai, Mohamed El-Qassas MVP
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Your question raise some ambiguity, whether its suitable for SP.SE or not. You have tagged SPO, so I am assuming you are syncing your On-Prem AD with Azure one. And you want to update details in your on-prem AD. If this is the case, then potentially this question will be closed. – Asad Refai Dec 21 '17 at 9:10
0

We use a tool from Dovestones for solving issues like this. They offer a bunch of softwares for Active Directory related use.

We use "AD Bulk Export" to export Active Directory objects to MS SQL Server. There we update attributes like department, employeeNumber and manager with values coming from SAP which are exportet to the same SQL Server. Then the tool "AD Bulk Users" imports the table back into Active Directory by scheduler. So AD is never outdated.

The tool works fine in our environment and pricing is good in my opinion. See the bundle "AD Toolset" which includes most of their tools.

0

You can use following powershell script to update multiple users information:

Function Update-ADUsers { 

$csvfile | ForEach-Object {  

$GivenName = $_.'First Name' 
$Surname = $_.'Last Name' 
$DisplayName = $_.'Display Name' 
$StreetAddress = $_.'Full address' 
$Sam = $_.UserName 
$City = $_.City 
$State = $_.State 
$PostCode = $_.'Post Code'  
$Country = $_.'Country/Region'  
$Title = $_.'Job Title' 
$Company = $_.Company 
$Description = $_.Description 
$Department = $_.Department 
$Office = $_.Office 
$Phone = $_.Phone 
$Mail = $_.Email 
$AccountExpires = $_.AccountExpirationDate 
$Manager = $_.Manager 

If($SAMinAD -eq $sam -and $SAMinAD -ne $null ) 
{ 

#added the 'if clause' to ensure that blank fields in the CSV are ignored. 
#the object names must be the LDAP names. get values using ADSI Edit 
IF ($DisplayName) { Set-ADUser -server $Server -Credential $Cred -Identity 
$sam -Replace @{displayName=$DisplayName} } 
Else {"DisplayName not set for $DisplayName because it is not populated in 
the CSV file" | Out-File $logfile -Append } 
IF ($StreetAddress) { Set-ADUser -server $Server -Credential $Cred -Identity 
$sam -Replace @{StreetAddress=$StreetAddress} } 
Else {"StreetAddress not set for $DisplayName because it is not populated in 
the CSV file" | Out-File $logfile -Append } 
IF ($City ) { Set-ADUser -server $Server -Credential $Cred -Identity $sam -
Replace @{l=$City} } 
Else {"City not set for $DisplayName because it is not populated in the CSV 
file" | Out-File $logfile -Append } 
If ($State) { Set-ADUser -server $Server -Credential $Cred -Identity $sam -
State $State } 
Else {"State not set for $DisplayName because it is not populated in the CSV 
file" | Out-File $logfile -Append } 
IF ($PostCode) { Set-ADUser -server $Server -Credential $Cred -Identity $sam 
-Replace @{postalCode=$PostCode} } 
Else {"PostCode not set for $DisplayName because it is not populated in the 
CSV file" | Out-File $logfile -Append } 
#Country did not accept the -Replace switch. It works with the -Country 
switch 
IF ($Country) { Set-ADUser -server $Server -Credential $Cred -Identity $sam  
-Country $Country } 
Else {"Country not set for $DisplayName because it is not populated in the 
CSV file" | Out-File $logfile -Append } 
IF ($Title) { Set-ADUser -server $Server -Credential $Cred -Identity $sam -
Replace @{Title=$Title} } 
Else {"Job Title not set for $DisplayName because it is not populated in the 
CSV file" | Out-File $logfile -Append } 
IF ($Company ) { Set-ADUser -server $Server -Credential $Cred -Identity $sam 
-Replace @{Company=$Company} } 
Else {"Company not set for $DisplayName because it is not populated in the 
CSV file" | Out-File $logfile -Append } 
IF ($Description ) { Set-ADUser -server $Server -Credential $Cred -Identity 
$sam -Replace @{Description=$Description} } 
Else {"Description not set for $DisplayName because it is not populated in 
the CSV file" | Out-File $logfile -Append } 
IF ($Department) { Set-ADUser -server $Server -Credential $Cred -Identity 
$sam -Replace @{Department=$Department}  } 
Else {"Department not set for $DisplayName because it is not populated in 
the CSV file" | Out-File $logfile -Append } 
IF ($Office) { Set-ADUser -server $Server -Credential $Cred -Identity $sam -
Replace @{physicalDeliveryOfficeName=$Office}  } 
Else {"Office not set for $DisplayName because it is not populated in the 
CSV file" | Out-File $logfile -Append } 

} 

About information that you want to remove, you can set those fields blank.

This is a reference about PowerShell Module for Active Directory Bulk-User Management:

https://gallery.technet.microsoft.com/scriptcenter/Active-Directory-Bulk-9c5271b2

Not the answer you're looking for? Browse other questions tagged or ask your own question.