Hello,
Below a script that can help, I've tested it.
It will export a list of users before the modification and you will have a status column which will tell you if the modification was successful:
$colExportUser = @()
$users = Get-ADUser -Filter * -Properties Description,Title | Where-Object {$_.Description -ne $_.Title}
foreach($user in $users) {
try {
Set-ADUser -Identity $user.SamAccountName -Title $user.Description -ErrorAction Stop
$hash = @{
Name = $user.Name
SamAccountName = $user.SamAccountName
Enabled = $user.Enabled
Description = $user.Description
Title = $user.Title
DistinguishedName = $user.DistinguishedName
OperationStatus = $true
}
$objExportUser = New-Object PSObject -Property $hash
$colExportUser = $colExportUser + $objExportUser
}catch {
$hash = @{
Name = $user.Name
SamAccountName = $user.SamAccountName
Enabled = $user.Enabled
Description = $user.Description
Title = $user.Title
DistinguishedName = $user.DistinguishedName
OperationStatus = $false
}
$objExportUser = New-Object PSObject -Property $hash
$colExportUser = $colExportUser + $objExportUser
}
}
$colExportUser | Export-Csv -Delimiter ";" -Path <yourpath> -NoTypeInformation