0 votes

I need to create a scheduled task that disables AD accounts if inactive for 30 days and then send me an email that it has run. I've got the account disable part working but i can't get it to send me 1 email for every account that was disabled but i need it to work once if it disabled any accounts or not.

by (60 points)

1 Answer

0 votes
by (271k points)

Hello,

Unfortunately, it is not possible to check whether a user is inactive for a specific number of days. It can only be done for a number of weeks. As we understand, you need the scheduled task to disable inactive users and then send an email notification for each of them. In this case, the scheduled task should look like the following: image.png If this is not what you need, please, describe the desired behavior in all the possible details with live examples.

0

This worked great but i'm having two issues.

  1. The task will re-run on users that are already disabled. Can i set it to only disable enabled users?
  2. It sends an email for every OU and then sends an email with the full list it disabled. So I end up with almost 100 emails when the task completes.
0

Any update?

0

Hello,

Sorry for the delay.

The task will re-run on users that are already disabled. Can i set it to only disable enabled users?

Yes, it is possible. We will update the script accordingly.

It sends an email for every OU and then sends an email with the full list it disabled.

Sorry for the confusion, but we are not sure what exactly you mean. Could you, please, post here or send us (support@adaxes.com) a screenshot of the scheduled task including its Activity Scope? Any additional details will be much appreciated.

0

Here is a screenshot of the task. 2021-04-01_9-08-02.png Here is an example of the Active Directory structure. I will get an email for each department inside location 1, then i will get an email that combines all of location 1 then i will get an email for each department inside location 2 and an email that combines all of locaton 2 once it reaches the last OU it will send an email that has every department at every location combined. 2021-04-01_9-09-30.png

0

Hello,

Here is a screenshot of the task.

The behavior occurs because the scheduled task is assigned over the Company users OU subtree, not the OU itself as it was shown in the post where we shared the initial script. To achieve the desired:

  1. Launch Adaxes Administration console.
  2. In the Console Tree, expand your service node.
  3. Navigate to Configuration\Scheduled Tasks and select the task you need.
  4. In the Activity Scope section on the right, select Company Users and click Edit below. image.png
  5. Select the The Organizational Unit object checkbox.
  6. Clear all the other checkboxes and click OK. image.png
  7. Save the changes. Finally, the Activity Scope of the task should look exactly like below (the Scope column should be This object only): image.png

Can i set it to only disable enabled users?

To achieve the desired, replace this line in the script

$filterUsers = "(sAMAccountType=805306368)"

with the below one:

$filterUsers = "(sAMAccountType=805306368)(!(userAccountControl:1.2.840.113556.1.4.803:=2))"

Related questions

0 votes
1 answer

Hi Team I am testing out a scheduled task to send out an email for password self service enrolment and located a previous question which suggested using the adm- ... or has the state of a users self service enrollment moved to another property?

asked Feb 26, 2021 by Richard_NRL (90 points)
0 votes
1 answer

Using the powershell module, I know how to create a scheduled task, and also how to bind to a scheduled task that is already known. I also have used code to try creating ... same time as another. These are all one-time tasks and will be removed once executed.

asked Jan 19 by aweight (40 points)
0 votes
1 answer

So I have custom forms for onboarding / offboarding users. We sometimes know 2-3 weeks in advance so I would like to add the ability to schedule these for the future. I ... to take all the data that was inputed and then process the request on the given date?

asked Aug 4, 2023 by thatcher (120 points)
0 votes
1 answer

Hello! how do i manage do get adaxes to remove all groups from the user after one month? We have a Business Rule where you can add an end of Date when the Account ... value field the powershell script works but not with the +1 Month. Thanks for your help!

asked Jun 14, 2023 by eww ag (140 points)
0 votes
1 answer

seting up a scheduled task to move users to thier correct OU. For some we can do this based on employee type and direct to a specific OU. For most of our users we will have to script this to move to the manager's OU.

asked Apr 12, 2023 by mightycabal (1.0k points)
3,340 questions
3,041 answers
7,764 comments
544,924 users