0 votes

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

0 votes
by (216k points)

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 <expiration status> 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.

0

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

0

Hello,

Yes.

Related questions

0 votes
1 answer

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

If I have a scheduled task powershell script that's targeting an OU of users and in that script I were to call $context.cancel in the case of an error happening for a single ... it cancel the entire scheduled tasks and it won't run for other users in that OU?

asked Oct 18 by wrichardson (20 points)
0 votes
1 answer

Hello, I've created a custom command to run a script which will send an email alert if the script encounters an error. I have the command set to run as a scheduled task ... script that sends it: Custom Command Name: Task Name: Time: Error Message: Thank you.

asked Sep 17 by GronTron (320 points)
0 votes
1 answer

Similar to Powershell's "whatif"? I'd like to enable this scheduled task - But would like to confirm who will actually be affected before enabling this. Is there at least ... objects in the console log? I could run that before adding the 'modify' actions back.

asked Jun 25 by msinger (210 points)
0 votes
1 answer

I want to create a scheduled task to disable a user if he is inactive for 30days, the task must check inacivity o AD and Azure.

asked May 16 by johanpr (120 points)
3,549 questions
3,240 answers
8,232 comments
547,814 users