How to update field in AD from a csv file

Hey.... I am trying to update fields in AD from a csv file.  For some reason whenever I run my code it is DELETING the title and not displaying the finished results in a new csv file. Please help. [ ]Write-host  "Processing"

Import-module ActiveDirectory

import-csv -path C:\Users\AliciaM\Documents\CurrentEmployees1.csv |
 
ForEach-Object{Get-ADUser -Filter “EmailAddress -eq `"$($_.EmailAddress)`""| Set-ADUser -Title $_.Title -Description $_.Description| Select CN, EmailAddress, Title, Description }  |

Export-csv C:\Users\AliciaM\Documents\FinalCurrentEmployeesResults.csv

Write-Host "Done"[/code]
Alicia MorganAsked:
Who is Participating?
 
oBdACommented:
In Set-ADUser, $_ is the output from Get-ADUser, not the csv row anymore.
And if you want output from Set-ADUser, you need to add the -PassThru argument
Write-Host "Processing"
Import-Module ActiveDirectory

Import-Csv -Path C:\Users\AliciaM\Documents\CurrentEmployees1.csv | ForEach-Object {
	$Row = $_
	Get-ADUser -Filter "EmailAddress -eq `"$($Row.EmailAddress)`"" |
		Set-ADUser -Title  -Description $Row.Description -PassThru |
		Select-Object CN, EmailAddress, Title, Description
} | Export-csv C:\Users\AliciaM\Documents\FinalCurrentEmployeesResults.csv
Write-Host "Done" 

Open in new window

0
 
oBdACommented:
Question answered.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.