I've the following Before Mofifying user job (Custom Command Delete):
Import-Module Adaxes
$user = Get-AdmUser "%distinguishedName%" -Properties MemberOf
if ($user.MemberOf -ne $Null)
{
foreach ($groupDN in $user.MemberOf)
{
Remove-AdmGroupMember $groupDN -Members $user -Confirm:$False
}
}
Start-Sleep -Seconds 5
I've also an After Modifying user job which executes several Custom Commands. The Custom Command adds the user to a group. After changing the department all group memberships are deleted so that works well. But the After job sometimes works completely and sometimes it works partially. Custom Command (1) sets group membership for all users and Custom Command (2) sets group membership based on department. For some reason the Custom Command 1 does not work randomly, in the logging it is stated that the user is added to those groups but that's not the case. Custom Command 2 is also executed and in the logging is stated the user is added to those groups, which indeed is the case.
I've also tested the Custom Command Delete in the After Modifying job with the same result.
How to solve this?
Thnx Remco