Im trying to update the "Manager" attribute in Active Directory from a CSV file using PowerShell but i have attribute email manager only and user attribute from initials.
example csv
initials |
mailmanager |
title |
department |
1234 |
jim@mail.com |
Accounting |
Finance |
4321 |
jim@mail.com |
Procurement |
Finance |
ForEach ($user in (import-csv -path "C:\script\testscript.csv"))
{
$dn = $user.user
$dm = $user.mail
Get-AdUser -Filter { Initials -like $dn } | set-aduser -manager $user.mailmanager -title $user.title -department $user.department
}
error:
set-aduser : Identity info provided in the extended attribute: 'Manager' could not be resolved. Reason: 'Cannot find
an object with identity: 'jim@mail.com' under: 'DC=domain,DC=com'.'.
when i change mailmanager to samaccountname, powershell success.