Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Updating AD users using a field from a CSV

$
0
0

Hi,

I was wondering is somebody could assist with a very simple process I am trying to complete but I just do not understand how.

I have the following piece of PowerShell below to query users in AD by their EmployeeID and works as expected.

Import-csv C:\Temp\raw.csv | ForEach-Object {
    $ID = $_.employeeID
    get-aduser -filter {employeeid -eq $ID} -Properties * | select-object emailaddress,employeeNumber,employeeID,surname,givenname | Export-Csv C:\Temp\exportADUser.csv -Append -NoTypeInformation

}

The headers in my CSV are as follows:

UserEmail,EmployeeNumber,EmployeeID,LName,FName

From the query above I would then like to update the EmployeeNumber for each AD user using the the value in the CSV.

I assume this will require the Set-ADUser cmdlet and the Foreach loop but I'm unsure how to amend my current PowerShell to get this working.

If anyone could assist that would be great.

Kind Regards

Dean


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images