Let's say that I have a scheduled task that adds a high-level roles-based AD group to a user.

As part of that same task, I'd like to run a powershell script to collect all the nested "child" groups from that roles-based "parent" group, and add those to the user as well.

Example - a new Marketing user is hired, so I add the roles-based group "Marketing Security Groups". But then for visibility, I want to also add all of the nested groups (Marketing Network Folder, Marketing SharePoint site, Marketing - Expense Application...) directly to that user's account.

We have the PowerShell script to do this, but the "parent" group (Marketing Security Groups) is hard-coded into a viariable in the script.

I could edit the PowerShell script each time it's used, and change the value. But instead, is it possible to set the variable to whatever group name is indicated in my scheduled task?

I'd envision the task to look like this:

Always:

  • Add "Marketing Security Groups" to User SmithJ
  • Run PowerShell Script "Add Nested Groups"

and then opening the PowerShell script, seeing something like:

$ParentGroupToExpand = %GroupFromTheTask%

Alternately, is there a way to prompt the technician creating the task to type in the "parent" group name, and pass it to the script that way?

ago by (190 points)

1 Answer

ago by (306k points)
0 votes

Hello Jake,

Unfortunately, there is no such possibility. You need to perform both parts (adding the target user to the role-based group and its nested groups) in the script. That is where you should have a relationship (probably hash table) between the user property value(s) and the groups.

As another option, you can try using rule-based groups. For details, have a look at the corresponding section of the following tutorial: https://www.adaxes.com/help/AddUsersToGroupsByDepartment.

Related questions

I have a scheduled task that runs a Powershell script against an AD group, "Group 1". I need to get all of the members of Group 1, and add them to Group 2. The ... identity in the error message start with 'user;'? What is the correct way to accomplish this?

asked Aug 27, 2019 by ngb (360 points)
0 votes
1 answer

I'm in the process of creating a Web interface for requesting IT accounts. Upon submission, I want to run a Powershell script that will create an item in a Sharepoint task list.

asked May 14, 2021 by sandramnc (870 points)
0 votes
1 answer

In a business rule, I'd like to pass Adaxes variables into a powershell script that I'll run. For example, pass %username% into the script so it can be used inside the script.

asked Sep 5, 2024 by P-Sysadmin (20 points)
0 votes
1 answer

Hi, I need to start Adaxes scheduled task from Powershell console running on another host. How can I do that?

asked May 21, 2020 by KIT (940 points)
0 votes
1 answer

Is there a way to have a Scheduled Task with 4 different condition? I want to create a scheduled task start every Monday and the condition see: The next Saturday of the week ... of the week is the fifth of the month then no action Thanks in advance, Simone

asked Jan 18, 2022 by Simone.Vailati (500 points)
0 votes
1 answer