I have a csv file of employee data in following format
empdata.csv
==================================================================================
empid,name,desig,dept,loc,grade,costcenter,division
5431,Zeeshan Qaiser Opel,Management Executive I,INFORMATION TECHNOLOGY,LAHORE,8,2260,INFORMATION TECHNOLOGY
==================================================================================
I need to get the employee id from the csv file, match it with user in AD, find the employees samaccountname and update the rest of the fields.
S
Script:
==================================================================================
Import-Module ActiveDirectory
Import-Csv "C:\empdata20.csv" |
ForEach-Object {
$EmpID=$.empid
$sam = {Get-ADUser -Filter "EmployeeID -eq '$($.empid)'" | select samaccountname}
Set-ADUser -Identity $sam -Replace @{employeetype=$Type}
Set-ADUser -Identity $sam -Replace @{title=$Desig}
}
==================================================================================