Trying to find if an AD CONTACT is listed a member/object of an AD group. Can someone please guide me to what I’m missing in my script below? The script below works if the object is listed as a member, but fails if its listed as a contact.
$users="Harris, Ella"
$Group ="#Yammer - Contractor Access"
$members = Get-ADGroupMember -Identity $group -Recursive | Select -ExpandProperty name
ForEach ($user in $users) {
If ($members -contains $user) {
Write-Host "$user in group"
} Else {
Write-Host "$user not in group"
}
}
#$userDistinName = (get-aduser $user).distinguishedname
#cn=harris\, ella,ou=employees,ou=ohcin,dc=corp,dc=local