Forum Discussion
Exchange Online Powershell not connecting in scheduled Task script
- Jan 13, 2025
It took me long time, but after creating a seperate scheduled script (only for testing Exchange Online connection), I finally found the issue.
The new script worked fine, so it had to be something about my old script.As it turned out, we had a Webserver API Call executing before the ExO connect in our script and I assume the connection never closed correctly. After I removed / moved this API call, the script is working fine.
Maybe it was blocking the same socket, which the script uses to connect to Exchange?Probably not really useful for you, but I hope it helps anyway.
Did you figure this out, im running into the same issue, script works fine manually (Certificate based authentication) but fails as a scheduled task.
It took me long time, but after creating a seperate scheduled script (only for testing Exchange Online connection), I finally found the issue.
The new script worked fine, so it had to be something about my old script.
As it turned out, we had a Webserver API Call executing before the ExO connect in our script and I assume the connection never closed correctly. After I removed / moved this API call, the script is working fine.
Maybe it was blocking the same socket, which the script uses to connect to Exchange?
Probably not really useful for you, but I hope it helps anyway.