0 votes

Hello,

I'd like the change the behavior of the account expires field from end of the day meaning 12am the next day to a specific time on the date specified.

Example 5pm on August 2nd instead of 12am on August 3rd.

The business rule I started out errors out for looping through. How would I change this and not create a loop?

I got the idea from here: https://mikefrobbins.com/2013/12/12/set ... owershell/

by (1.2k points)

1 Answer

0 votes
by (227k points)
selected by
Best answer

Hello,

The loop appears because the value set by the Modify the user action meets the conditions specified for the Business Rule. To avoid this and still set the Account Expires property as desired, you can use the Run a program or PowerShell script action with the below script instead of the Modify the user action. The script will update the Account Expires property directly in Active Directory, thus the Business Rule will not trigger again and there will be no corresponding record in Adaxes logs.

$valueToSet = "%accountExpires,,17:00%" # TODO: modify me

# Update the user
$Context.TargetObject.Put("accountExpires", $valueToSet)
$Context.TargetObject.SetInfo()
0

Brilliant, thank you!

Related questions

0 votes
1 answer

Is there a way to set a users' UPN Suffix within a business rule (PS script)? I've seen the script to update the suffix based on OU, but our OU structure ... primary email address, or to apply a particular UPN suffix based on department. Either method works.

asked Apr 3, 2017 by steve.newton (50 points)
0 votes
1 answer

I'm not entirely sure if this is possible using a business rule but what I am trying to achieve is have the business rule perform actions when a user account has expired. Can this be acheived or would a scheduled task be the preferred method?

asked Sep 21, 2020 by Richard_NRL (90 points)
0 votes
1 answer

We would like to create a ticket in our ticketing system after a user's account is unlocked. I would like to use a business rule to do this so that it happens automatically. I don't see an option for this. I only see "After updating a user:"

asked Feb 4, 2020 by mark.it.admin (2.1k points)
0 votes
1 answer

Let's say I have a Business Rule that is fired prior to adding members to a group. Is it possible to get the number of objects being added to that group as ... that tells me that 6 objects will be added or is each added user treated completely independently?

asked Apr 20 by ngb (90 points)
0 votes
1 answer

I'm building my first rule to license users in Office365. When the rule runs it fails to find the Usage Location which is based on the Country (default settings). I ... runs before the "assign 365 license" rule. Why am I not getting Usage Location populated?

asked Jul 20, 2020 by ComputerHabit (790 points)
2,801 questions
2,535 answers
6,605 comments
61,659 users