Let me preface this post with the fact that I’m extremely green when it comes to PS. (As in, today is my first day using it.) I’ve been tasked with updating a large number of AD user accounts with charge codes. It was decided that we should use the Department field for this. Unfortunately, the csv that was provided to me comes from an ancient Intranet where the only information that is useful that matched up to AD is the user’s employee number and charge code. The csv has the headers of User and Department. I know this should be a simple script, but I’m still getting my feet wet here, and am stumbling around in the dark, as it were. Any insight would be much appreciated.
$Userdata = Import-Csv C:\empID.csv ForEach ($User in $Userdata) { $User = $User.User $Department = $Department.Department Get-ADUser -Filter "EmployeeNumber -eq '$User'" -Properties * | set-AdUser -Add "'$User' -eq 'Department'" -Properties Department }