I'm working on a script where I want to email the results. The basic logic is working fine, but I'm having trouble with sending emails from the "Try" block. While I do receive an email when there's an error in the "Catch" block, nothing comes through for the successful execution of "Try". Below is the script snippet I've got so far, which retrieves DHCP filter logs for the last 24 hours and then tries to email the results. I'm looking for what might be going wrong. Thanks for any help!
3 Answers
You could also try adding some logging to see if the code is progressing to the email line in `Try`. Sometimes adding simple debug outputs before critical lines can reveal if the script is working as intended.
It seems like your `Get-WinEvent` might be encountering an error that's causing the `Catch` block to trigger instead of the email being sent from `Try`. Double-check if that command is completing successfully first. If there's no error message, it’s worth logging out the events to ensure they are being collected as expected.
You might want to verify that your `Try` block is actually closed properly. It looks like you might have missed closing it. It should encapsulate all the email functionality inside, so check that there are no missing braces. The absence of a proper scope might lead to unintended behaviors.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically