0 votes

I want to send out an email one time 60 days after an account expires. I was trying to set this up using the scheduled task, but it requires me to pick a schedule before I enter the conditions. So, if I select One time, it requires me to pick a date.

Is there any other to do this?

by (730 points)

1 Answer

0 votes
by (216k points)

Hello,

You can do this with a single Scheduled Task that runs each day. You can create a Scheduled Task that will check all accounts in your AD and will send e-mail notifications for those users, whose accounts expired 60 days ago. To create such a Task:

  1. Create a new Scheduled Task.

  2. On the 2nd step of the Create Scheduled Task wizard, select Daily and specify the time when the Task will run.

  3. On the 3rd step, select the User object type.

  4. On the 4th step, add the Send e-mail notification action and customize the notification settings in the lower part of the dialog.

  5. Click OK.

  6. Now, you need to add a condition when the notification will be sent. Double-click Always.

  7. To check whether a user's account expired 60 days ago, you will need to use a PowerShell script. Select the If PowerShell script returns True condition type.

  8. Paste the following script in the Script field.

     $Context.ConditionIsMet = $False
    
     $targetDate = (Get-Date).AddDays(-60).Date # 60 days prior to the current date
     $expirationDate = $Context.TargetObject.AccountExpirationDate.Date
    
     if ($targetDate -eq $expirationDate)
     {
         $Context.ConditionIsMet = $True
     }
    
  9. Add a short description for the script and click OK.

  10. Finish creation of the Scheduled Task.

Related questions

0 votes
1 answer

I have a scheduled task that "EXPIRES" user account for non-compliance of government directive. I send email to inform user with instructions. This email is sent to the ... . My question is How can the user access the email while account is expired?

asked Aug 2 by hhsmith (100 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

We need to run a scheduled task twice a year, so I chose every 182 days like it's suggested in here, only problem is that there is no way to change the next run ... really don't want these tasks to be triggered again if they've already been executed this year.

asked May 8 by boing (20 points)
0 votes
1 answer

Hi, we currenlty have a business rule to send an email everytime the Title, Manager, Department, accountExpires, EmployeeType or FirstName attributes are ... Unit: %BusinessUnit% End Date: %accountExpires% Effective Date of Change: %adm-CustomAttributeDate2%

asked Feb 14 by KevC (60 points)
0 votes
1 answer

I would like to delete users that have been disabled for more then X number of days. This would be a phase of our deprovisioning process. The user is first disabled and placed ... we are sure that we no longer need it, I would like to automaticially delete it.

asked Oct 13, 2022 by rmedeiros (380 points)
3,549 questions
3,240 answers
8,232 comments
547,814 users