Hello Mark,
As we mentioned in the previous post, the script performs removal from group directly in AD avoiding Adaxes pipeline. For the pipeline to be applied, you need to specify the -AdaxesService and -Server parameters when executing the Remove-AdmGroupMember cmdlet. For details, have a look at the following SDK article: http://adaxes.com/sdk/Remove-AdmGroupMember. We updated the script accordingly, find it below. In the script, you need to replace the value of the -Server parameter with the required one.
$UserDN = "%distinguishedName%"
# Get DNs of current groups the user is member of
try
{
$groupDNs = $Context.TargetObject.GetEx("memberOf")
}
catch
{
$Context.LogMessage("User %name% is not a member of any groups.", "Information")
return
}
# Remove from all appropriate groups
foreach ($groupDN in $groupDNs)
{
if (-not($groupDN -like "*OU=SpecificOU*"))
{
continue
}
$Context.LogMessage("Removing from: $groupDN", "Information")
Remove-AdmGroupMember -Identity $GroupDN -Members $UserDN -AdaxesService localhost -Server "dc.domain.com" -Confirm:$false
}