I'm trying to build a simple scheduled task but having no success:

If the 'Account Expires' property is less than or equal to '%datetime,+30d%' AND
the 'Relationship' property equals 'Contractor' OR
the 'Relationship' property equals 'Agency Contract Temp' then
Send e-mail notification (%displayName%'s Account will expire on %accountExpires%. )

First, changing one logical operator in the IF statement changes the second logical operator automatically. I can only get 2 ORs or 2 ANDs in the above statement. Is it possible to have a mix of logical operators in the IF statement?

Second, if it is possible what is the order of precedence?
And can statements be grouped as in:
statement1 AND (statement2 OR statement3)?

by (520 points)

1 Answer

by (216k points)
0 votes

Hello,

Currently, combining different operators within the same set of actions and conditions is not supported. You can use either OR or AND operator within a set. Also, grouping of conditions is not supported.

To workaround this, you can use several sets of actions and conditions within a Scheduled task. For example, in the above case, the Scheduled Task can be set up as follows:

To add an action to a new action/condition set, use the Add action to a new set link.

Also, we strongly do not recommend checking for account expiration by directly checking the value of the Account Expires property. The thing is that when an account is set up to never expire, the value of the Account Expires property equals 0. So, if your condition is If the 'Account Expires' property is less than or equal to '%datetime,+30d%', the condition is also met for all accounts that never expire, because 0 will always be less than the current date. We recommend the If account/password condition. This condition type properly handles accounts that never expire.

Alternatively, if you are planning to build a very complicated structure of conditions, you can use the If PowerShell script returns True condition and checks all the conditions that you need with the help of the if/else/elseif statements in the script.

For an example of how to use the condition, see the step 6 of the Validate/Modify User Input Using a Script Tutorial.

by (520 points)
0

Thank you for your guidance.
Will the account/password condition also ignore expiration status = unspecified?

by (216k points)
0

Hello,

Yes.

Related questions

Greetings! Is there a way to have multiple logical operators in a business rule? I can create a rule with 'If this AND that AND the other thing, THEN do ... helpdesk staff from modifying group membership for a handful of sensitive AD groups. Thanks! Marty

asked Jan 4, 2017 by bouillon (150 points)
0 votes
1 answer

Hello, We have a task which checks every hour if jobs have been added to a list (CSV-File) and if so will start provisioning tasks including Microsoft Teams. If ... job has completed or is still running to prevent duplicate runs. Is this somehow possible?

asked Sep 25 by andrep (20 points)
0 votes
1 answer

Let's say that I have a scheduled task that adds a high-level roles-based AD group to a user. As part of that same task, I'd like to run a powershell script to collect all ... the task to type in the "parent" group name, and pass it to the script that way?

asked Sep 22 by 3Jake (190 points)
0 votes
1 answer

We have a security initiative to disable the default Exchnage Online (EXO) PowerShell access for users, while retaining access for Admins. I would like to implement ... com/en-us/powershell/exchange/disable-access-to-exchange-online-powershell?view=exchange-ps

asked Mar 14 by Mark.Monaco (40 points)
0 votes
1 answer

How do we set up an e-mail notification (only once per user) as an scheduled task (ex. every hour) based on the property "accountExpires"? Some background: Our HR-software ... to achive this result, do you have any suggestions on how to solve it another way?

asked Jan 17 by Handernye (120 points)
0 votes
1 answer