mail is going out twice a day to users

Post Reply
cires316
Posts: 18
Joined: Fri Jan 19, 2018 11:33 pm

mail is going out twice a day to users

Post 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?

User avatar
Cubert
Posts: 1414
Joined: Tue Dec 29, 2015 7:57 pm
Contact:

Re: mail is going out twice a day to users

Post by Cubert »

yea that should not be doing that, I'll look at it here to see if something changed.

cires316
Posts: 18
Joined: Fri Jan 19, 2018 11:33 pm

Re: mail is going out twice a day to users

Post by cires316 »

Find anything yet?

benarm
Posts: 2
Joined: Sun Mar 15, 2020 12:08 am

Re: mail is going out twice a day to users

Post 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.

User avatar
Cubert
Posts: 1414
Joined: Tue Dec 29, 2015 7:57 pm
Contact:

Re: mail is going out twice a day to users

Post 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 1580 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.

benarm
Posts: 2
Joined: Sun Mar 15, 2020 12:08 am

Re: mail is going out twice a day to users

Post by benarm »

Hi Cubert, that worked fine. Thanks for the help.

Post Reply