Using Send-MailMessage but the Changed event firing on the Create event

I know that the Send-MailMessage has been deprecated but i have not found an alternative. until i do, the problem that i am having is the Changed event that fires (twice) on a file creation. just need to know that this is the default behavior and can’t be changed. below is my snippet on the event.

    Register-ObjectEvent $watcher "Created" -Action $action
    Register-ObjectEvent $watcher "Changed" -Action $action2

so the default folder that it is looking at is W:\PO Files. what is working is the Created event. that fires (once) when the file is created so if i comment out the Changed event, then everything works and only one email is sent to me.

however if i uncomment out the Changed event and then create a file in PO Files, then Send-MailMessge sends out three emails, one for the Created and two for the Changed. Was hoping that the Changed event was only for files that were updated (meaning that they were previously created, and then a new version was saved, thus firing of the Changed event). did the requisite google search and couldn’t find any valuable info on the Changed event.

Can someone shed some light on this?

I’d say it is pretty unlikely because you do not share enough information and code. Could you please post either the entire script or at least the relevant code? (formatted as code please)

Edit:
Taking a wild guess I’d suspect this could help you:

Olaf,

posted all the code to my first post (not this one) which has the full ps1 code in it. do you still want me to post the code here?

as for FSW, im using that.

No. Once is enough. :+1:t4:

Changed event firing twice is a pretty commonly encountered and discussed issue