Hello @Aleksej Egorov
Welcome to Microsoft Q&A!
Thank you for your patience, and taking the time to elaborate on your concerns.
This difference is expected: scheduled tasks run under a non‑interactive logon type and do not inherit cached credentials from your interactive session. That’s why implicit authentication fails, but explicit credentials succeed.
Key Points.
Interactive vs. scheduled context: Interactive sessions can reuse cached Kerberos/NTLM tokens; scheduled tasks cannot.
Task Scheduler logon type: Runs as LOGON_BATCH, which restricts credential delegation.
OS changes: Newer Windows builds enforce stricter credential handling compared to Server 2022.
Fix Options.
- Run the task under a service account with SMTP permissions.
Store credentials securely using Export-CliXml / Import-CliXml and load them in the script.
Check Task Scheduler settings:
“Run whether user is logged on or not” (requires stored password).
“Run with highest privileges.”
Consider modern authentication (OAuth, certificates) if your Exchange/SMTP server supports it.
Relevant Documentation.
Note: Scheduled tasks don’t inherit your interactive credentials. Use a service account or securely stored credentials (Import-CliXml) to ensure reliable email sending. Modern auth methods are recommended if available.
I hope this helps to better understand the diagnostic options available and the risks involved.
If this information was helpful, please click Accept Answer.
Thank you for choosing Microsoft Q&A.