Hello,
The first solution that Nodeblue suggested will not work in this case. The thing is that the suggested script checks the Managed By property of a group. This property specifies the owner of the group in question. However, mdeflice asked for a solution that would check managers of users. User managers are specified in the Manager property of their accounts.
As to the solution requested, the easiest way to achieve your task would be to add a set of actions and conditions that would add the manager to the group. In the case that you provided as an example in your screenshot, you can check, for example, if the username equals to Vinnie Paul's username and add the user to the group, if it equals. To do this:
- Launch Adaxes Administration Console.
- In the Console Tree, navigate to the Custom Command that you've created and select it.
- Click the Add action to a new set link.
- Select the Add the user to a group action and click Select Group.
- In the dialog box that appears select the group you need (e.g. AdaxesTestDallDG) and click OK two times.
- Double-click Always.
- Select the If <property> <relation> <value> condition.
- Select User Logon Name (pre-Windows 2000) equals and type Vinnie Paul's SAMAccountName.
- Click OK and save the Custom Command
Also, you will need to add a condition to the second set of actions and conditions that checks if the username does not equal to Vinnie Paul's username. This condition is required not to remove Vinnie Paul from the group. To add such a condition:
- Select the second set of actions and conditions.
- Click the Add Condition button.
- In the dialog box that appears, select the If <property> <relation> <value> condition.
- Select User Logon Name (pre-Windows 2000) does not equal and type Vinnie Paul's SAMAccountName.
- Click OK and save the Custom Command.
You should end up with a Custom Command that is similar to this one:
However, if you want to further automate the process, you can use PowerShell scripts. For example, you can create a PowerShell script that will be launched from your Custom Command using the Run a program or PowerShell script action. Also, you can create a CSV file containing two columns. The first column will contain the name of a manager, and the second one will contain the name of the group that his team should be added to. When the PowerShell script runs, it will read the information from the CSV file and add the Manager specified in the CSV file and also his direct reports to the group specified for that manager in the second column. Also, the script can remove the members that no longer belong to the manager's team. Also, if you change a manager in the CSV file, he will also be removed from his group.
For examples on how to add or remove members to or from a group using PowerShell, see Adding and Removing Group Members. For examples on how to get group members, see Getting Group Members. Also, take a look at the Automatically Change Group Membership Using Scripts Tutorial. For an example on how to import a CSV file using PowerShell, see the Import CSV File Using PowerShellShell section in the Import User Accounts from a CSV File Tutorial. If you want, we can help you with the script.