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

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

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)
0 votes
1 answer

We have four OUs in Active Directory (Pending Deletion, Disabled with Mail Delegates, Disabled with HR Extensions and Disabled_Temp_Leave) that users are moved to prior to their eventual ... past 7 days have been moved to one of 4 of these OUs. Thanks!

asked Jun 3, 2021 by RayBilyk (230 points)
0 votes
1 answer

We have RBAC groups inside an OU. We would like to restrict users from being added to multiple RBAC groups at a time. For example: RBAC Roles OU Sales RBAC Group ... groups outside of this OU structure though. What's the best way to achieve this? Thanks

asked Oct 13, 2021 by bavery (250 points)
3,349 questions
3,050 answers
7,791 comments
545,066 users