0 votes

Hi all,

I need some help with this builtin script. It's a good foundation for what I'd like to do but I need to be able to keep the user in two groups (one, really, if it exists).

I need to keep them in:

* Domain Users
* MLGX Users (this is our Metalogix Archive Manager group).

If they are a part of the MLGX group, I want them to keep that group membership. If the MLGX group membership is not seen, do nothing and simply keep them in the Domain Users group only.

Also, I'd like to see if the following is possible (please see the screenshot)
The rule is: If there is a manager, set forwarding to the manager.
How can I add: If there is no manager, e-mail IT and notify the team that forwarding was not set. (unless there is a better method to achieving this, some kind of output log of the tasks completed on the deprovisioned user)..

Thank you!

by (100 points)
0

Reviewing this in some more depth, is it also possible to remove any phone partnerships with Exchange? What I want is to disable the user's access to e-mail IMMEDIATELY when we receive notification of their termination as part of this Deprovisioning.

-- I think I found the answer to this particular question.

1 Answer

0 votes
by (251k points)
selected by
Best answer

Hello Adrian,

I need some help with this builtin script. It's a good foundation for what I'd like to do but I need to be able to keep the user in two groups (one, really, if it exists).

Find the updated script below.

$groupNamesToSkip = @("MLGX Users")

# Get all groups user is a direct member of
$groupGuids = $Context.TargetObject.GetEx("adm-DirectMemberOfGuid")

# Get the Primary Group ID
$primaryGroupId = $Context.TargetObject.Get("primaryGroupID")

foreach ($groupGuidBytes in $groupGuids)
{
    # Bind to the group
    $groupGuid = New-Object "System.Guid" (,$groupGuidBytes)
    $groupGuid = $groupGuid.ToString("B")
    $groupPath = "Adaxes://<GUID=$groupGuid>"
    $group = $Context.BindToObject($groupPath)
    $groupName = $group.Get("cn")

    # Skip the group if it is the user's Primary Group
    if (($group.Get("primaryGroupToken") -eq $primaryGroupId) -or ($groupNamesToSkip -contains $groupName))
    {
        continue
    }

    # Remove user from the group
    $group.Remove($Context.TargetObject.AdsPath)
    $Context.LogMessage("Removed the user from group '$groupName'", "Information")
}

How can I add: If there is no manager, e-mail IT and notify the team that forwarding was not set. (unless there is a better method to achieving this, some kind of output log of the tasks completed on the deprovisioned user)..

You can achieve this by adding another set of actions and conditions to the Scheduled Task. To do so:

  1. Launch Adaxes Administration Console.
  2. Navigate to Configuration\Scheduled Tasks and select the task.
  3. Click Add action to a new set in the Result Pane.
  4. Select Send e-mail notification.
  5. Specify Action Parameters and click OK.
  6. Double-click Always.
  7. Select If <property><relation><value>.
  8. Select If Manager is empty.
  9. Click OK and save the changes.
0

You guys rock!! I'm going to test this tomorrow. Thank you so much!

Related questions

0 votes
1 answer

Hi, I would like to use the custom commands to deprovision an AD user. Is there a way to automatically remove all groups (besides Domain Users which cannot be removed) from a user? Thanks...

asked May 1, 2014 by decop (20 points)
0 votes
1 answer

In the de-provisioning process, I need to remove all users from all Office 365 groups (UnifiedGroups). I tried to adapt this script but unsuccessfully. https://www.adaxes.com/script-repositor ... -s360.htm Is there any way to do this?

asked Sep 22, 2019 by flaviodouglas (70 points)
0 votes
1 answer

Hi Guys, I'm trying to clean all users from Local Group test_group, and next new bunch of users form TXT fiel, by executing the following script as a scheduled task Import-Module ... .txt I have only 600 users. Do you have any idea how to improve this script?

asked Feb 27, 2015 by axmaster (510 points)
0 votes
1 answer

I created a task to delegateremoving users from distribution groups but i am not able to see a list of groups. The same settings are being used in teh add to distribution group which works correctly. settings:

asked Jan 23 by Derek.Axe (460 points)
0 votes
1 answer

I'd like to allow users to remove themselves from groups that they are already members of. Currently I have a business rule in place thats only allowing the OU Owners ... user is a member of the adm-groupname' then allow then to remove themselves.

asked Apr 30, 2020 by sirslimjim (480 points)
3,071 questions
2,784 answers
7,155 comments
434,063 users