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 (250 points)

1 Answer

0 votes
by (198k 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 by Richard_NRL (480 points)
0 votes
1 answer

On Approval Requests, in the web console, Initiator shows "N/A" instead of the custom command scheduled task. The admin console shows the custom command scheduled task though. Any way to fix that?

asked Jan 21 by mark.it.admin (7.1k points)
0 votes
1 answer

I have a scheduled task that runs a PowerShell script. The script checks various properties of each user, and uses $Context.LogMessage to report on properties that are not ... (doesn't have to be LogMessage) into a single report or single notification email?

asked Oct 13, 2020 by jcrook (250 points)
0 votes
1 answer

We are using Adaxes to manage multiple domains. upwards of 10 domains. There is no trust between the domains. The are all separate stand alone. We want to setup a scheduled ... domain has an Adaxes service account setup and that is what i would want to use.

asked Sep 14, 2020 by gt_111 (250 points)
0 votes
1 answer

I am trying to send a $context.logmessage from a condition script in a Scheduled Task but I get nothing in the log. Is this not possible? Morten A. Steien

asked Jul 20, 2020 by Morten A. Steien (740 points)
2,445 questions
2,197 answers
5,905 comments
287,885 users