Hi,
I have a piece of PS code being called by Adaxes and I'm trying to email each AD group member after they are removed from an AD group.
Currently I am unable to find a simple way of retrieving the email address. It looks (as far as I can tell) that the email (mail) attribute is not being stored when the user objects are retrieved - my code snipped is as below where the $emailto variable is always coming back blank (but I can change to .Name etc and it does pull back the correct data for that field).
Is there a simple way to include the mail attribute in the search? Note that I have tried $member.Get("mail") also.
Thanks
Import-Module Adaxes
$groupMembers = Get-AdmGroupMember -Identity "%distinguishedName%" -Server "lan.net" -AdaxesService localhost
ForEach ($member in $groupMembers)
{
Remove-AdmGroupMember -Identity "%distinguishedName%" -Members $member -Server "lan.net" -AdaxesService localhost -Confirm:$False
$Context.LogMessage("User removed: " + " $member", "Information")
$emailto = $member.mail
...