I have a scheduled task which executes a PowerShell script when an user account is deleted from Active Directory. Is there a way to check the group membership of that user account ? I have tried with
If ((Get-ADUser $user -Properties MemberOf | Select -ExpandProperty MemberOF) -ccontains $groupname)
{
//code
}
but unfortunately, this didn't worked.(and is understandable why).
I was thinking at something as using a customized xml file for the creation of the scheduled task, but neither in this case, I don't know which value I have to query.
Any ideas?