Updating AD Manager (from mail manager) Attribute from CSV using PowerShell

asked 2023-01-12T02:34:00.15+00:00
lucky alqodar 41 Reputation points

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 


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.

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
3,595 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2023-01-12T12:58:45.7533333+00:00
    BOURBITA Thameur 11,146 Reputation points Microsoft MVP


    The manager attribute must contain the distinguishedName of the Manager not his mail or samaccountname.

    To resole your issue , you have to set the distinguishedName of the manager instead the mail.

    Manager attribute contains the distinguished name of the user who is the user's manager

    Please don't forget to mark helpdul reply as answer

    No comments