Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, July 6, 2017 5:00 PM
I have a script that matches a contact based on an email in a csv, I can find the contact using a get-adobject -ldapfilter but when I try to add the contact as a manager the add fails stating it cannot find the contact. The contact it states it cannot find is clearly present in the directory.
This line will find the contact:
$rmanager = Get-ADObject -SearchBase 'OU=workplace,OU=Contacts,DC=office,DC=com' -ldapfilter "(&(objectclass=contact)(name=$fname*)(name=*$lname))"
An example of the contact in question being found...
PS C:\temp> Get-ADObject -SearchBase 'OU=workplace,OU=Contacts,DC=office,DC=com' -ldapfilter "(&(objectclass=contact)(name=$fname*)(name=*$lname))"
DistinguishedName Name ObjectClass ObjectGUID
CN=Nick Hill,OU=workplace,OU=Contacts,DC=office,DC=com Nick Hill contact b649bd7e-aac9-4d4b-8203-b6a79f35b91
However, this line with the set-aduser will fail stating it cannot find the contact that clearly exists...
get-aduser -f {mail -eq $username} |set-aduser -Manager "$rmanager"
set-aduser : Identity info provided in the extended attribute: 'Manager' could not be resolved. Reason: 'Cannot find an object with identity: 'CN=Nick Hill,OU=Workplace,OU=Contacts,DC=office,DC=com' under: 'DC=Office,DC=com'.'.
All replies (1)
Thursday, July 6, 2017 10:27 PM
You cannot use a contact as a manager. You must use a full AD Account object or its DistinguishedName.
\(ツ)_/