Page 1 of 1

mail is going out twice a day to users

Posted: Mon Nov 18, 2019 8:06 pm
by cires316
I think it's supposed to be only sending once a day isn't it?

It looks like the system is emailing the users just after midnight and just after 1 pm every day. Is this something I can change or is it a bug?

Re: mail is going out twice a day to users

Posted: Tue Nov 19, 2019 1:35 pm
by Cubert
yea that should not be doing that, I'll look at it here to see if something changed.

Re: mail is going out twice a day to users

Posted: Thu Nov 21, 2019 6:54 pm
by cires316
Find anything yet?

Re: mail is going out twice a day to users

Posted: Wed Mar 18, 2020 12:47 am
by benarm
Hi Cubert,

As you mentioned in another forum thread, the scan runs as a scheduled script twice a day. Once at midnight then again at 1pm. Can this schedule be modified as it causes the notification to go out to users twice a day? Thank you.

Re: mail is going out twice a day to users

Posted: Wed Mar 18, 2020 1:46 pm
by Cubert
It can be yes,

We have this modification in our Habitat AD Password Notifier to resolve that very issue. Here is what you can do to resolve it in Expiry.


Capture.PNG
Capture.PNG (15.5 KiB) Viewed 18157 times

Edit the Expiry script located in the /scripts/maintenance/ script folder on your automate console.

Find line 16 and start adding new functions and notes as shown in image above.


We are basically breaking the script in half so that the AD scans run twice a day but the emails only run once (after 8 am). To do this we created a small powershell script that if current time is between 8 am and 4 pm it just echos "sendmail". we save that as an output to a variable and then test that variable to see if it contains "sendmail" if so we jump to :STARTEMAINGUSERS where we continue on doing the sending of email portion of script. If we get no return or not the "sendmail" we are expecting from POSH then we quitely quit the automate script.


Here is that powershell script

Code: Select all

$min = Get-Date '8:00'
$max = Get-Date '16:00'
$now = Get-Date

if ($min.TimeOfDay -le $now.TimeOfDay -and $max.TimeOfDay -ge $now.TimeOfDay) {
  # send mail
   write-output "sendmail"
}
I hope this helps.

Re: mail is going out twice a day to users

Posted: Wed Mar 25, 2020 8:02 am
by benarm
Hi Cubert, that worked fine. Thanks for the help.