Account Expires - Select only 3 weeks in to the future

Hi Team. 

I have created a new user form to allow specific teams to create basic test accounts. The form itself is working and creating the user account how we want it. I then have a Workflow that picks up the account, moves it to an OU, sends an email to the team, etc. 

As these are test accounts, we don't want them to be active for more than three weeks at a time. 

I have added the accountexpires attribute to the form, but of course, I can select any date I want in the future. Is there a way with a PGV or some other cleave way that I can restrict access to only three weeks in advance

Cheers

Craig 

Top Replies

Parents Reply
  • Hi  

    Sorry, forget accountExpires is an Integer8 attribute, so it might not be converting it to a date time format... try this instead

    1) Create powershell script module, as below, where the $MaxDays value is how long in days from the current date is the evaluation date

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

    2) Modify the IF statement of your workflow

    If the script returned true (IE the account has an eccountExpires value greater than the eval date), you'll go down the If branch, otherwise the else branch

Children