0 votes

Is there a way to have a Scheduled Task with 4 different condition? I want to create a scheduled task start every Monday and the condition see:

The next Saturday of the week is the first of the month then take a action The next Saturday of the week is the second of the month then take a different action The next Saturday of the week is the thirt of the month then take a different action The next Saturday of the week is the fourth of the month then take a different action The next Saturday of the week is the fifth of the month then no action

Thanks in advance, Simone

by (270 points)

1 Answer

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

Hello Simone,

Yes, it is possible. You will need to use a scheduled task executed every Monday. In the task conditions, use the below script to determine whether the next Saturday matches the specified number. In the script, the $requiredNumber variable specifies the number that should be matched.

$requiredNumber = 3 # TODO: modify me

$date = (Get-Date).AddDays(-5)
$weekdayCalc = [int][Math]::Floor($date.Day / 7)
$weekdayNum = if ($date.Day %% 7 -eq 0) {$weekdayCalc} else {$weekdayCalc+1}

$Context.ConditionIsMet = $requiredNumber -eq $weekdayNum

Finally, the scheduled task will look like the following: image.png

Related questions

0 votes
1 answer

We have four OUs in Active Directory (Pending Deletion, Disabled with Mail Delegates, Disabled with HR Extensions and Disabled_Temp_Leave) that users are moved to prior to their eventual ... past 7 days have been moved to one of 4 of these OUs. Thanks!

asked Jun 3, 2021 by RayBilyk (220 points)
0 votes
1 answer

For example, if the scope is a specified OU, running the report will list management history for every object in the OU even if it has had no management operations ... so objects that have not had any recent modifications are excluded from the report results?

asked Aug 13, 2021 by ryan741 (120 points)
0 votes
1 answer

I am wanting to export a list of users including the properties of a specific custom attribute. Ideally, I would be able to run a get-admuser and filter on a custom attribute, but even an excel report with the custom attributes would work. Is this possible?

asked Sep 9, 2021 by ggallaway (300 points)
0 votes
1 answer

Is there a way to pull a report within Adaxes to find out how many computer objects a user will have associated to them?

asked Mar 2 by Tarun Sharma (20 points)
0 votes
1 answer

When we deprovision a user the member of groups are deleted and the power shell scrips only runs as removing all memberships. I can't see what was removed. Is there a scrips I can run prior to removing those memberships that will e-mail what they are?

asked Oct 15, 2019 by meyerm (50 points)
2,803 questions
2,535 answers
6,605 comments
62,185 users