Expired Accounts life cycle

Hi Team.

Just looking for some suggestions on the best way forward.

I have a new user form that is just creating a temp AD user. Very basic account and that account by default has a 21 days account expiry set at creation time.

Now what we are wanting to do is

1) Account created with 21 days until account expires.

2) At 14 and 19 days send an email to the person who created the account with a Keep or Delete approval type email

3) If no response at 21 days then disable the account

4) If person who created the account clicks Keep then the account expiry is extended 21 days

5) If person clicks Delete then the account is automatically deleted

Based on the above do you think this would typically be a single work flow? Would it be easier to put the accounts in a group and have the check performed on the group members?

Just trying to work out the best approach to this.

  • Running as scheduled task does not include a approval so not 100% sure how i can do this 

  • I would use more than one workflow. A scheduled workflow to run daily and check virtual attributes that  contains data such as dates, or days. Then I'd create another workflow based on virtual attribute changes, then initiate the approval from there. 

  • Thanks, 

    Yes i had come to the same conclusion and approach and started to work down that path so thank you validating my thinking. 

    I am trying to reuse the script  provided which works great in a new user workflow. I am trying to use this in a scheduled task workflow.

    The plan is the workflow will run on a schedule. it searches a AD group that contains all the accounts i want to check the accountexpires on. If it find an account and the script returns true then set the VA on the workflow to TRUE

    When the workflow runs it displaying the error 

    Activity 'If-Else Branches' encountered an error.
     Details <<<
    At line: 16 char:5. Exception calling "Get" with "1" argument(s): "Object reference not set to an instance of an object."

    function Convert-Int8ToDateTime($Request)
    {
        $MaxDays = 21
    
        $EvalDate = (Get-Date).AddDays($MaxDays)
       
        $Int8 = $Request.get("accountExpires")
        $Return = "FALSE"
       
    
        if($Int8)
        {    
            if([DateTime]::FromFileTimeUTC($Int8) -ge $EvalDate)
            {
                $Return = $TRUE
                #throw "TRUE"
            }
        }
        
        return $Return
    }