This forum is closed. Thank you for your contributions.
Hi,
I want a powershell script that will look at all contacts in AD to see if there a member of a group, If not in a group contact can be deleted.
To retrieve all contacts that not a member of any group, you can use:
$Contacts = Get-ADObject -LDAPFilter "(&(objectClass=contact)(!(memberOf=*)))"
User Remove-ADObject to remove the contact:
https://docs.microsoft.com/en-us/powershell/module/addsadministration/remove-adobject?view=win10-ps
Richard Mueller - MVP Enterprise Mobility (Identity and Access)