Hi @Kuwada Hiroyuki--ITSL900 ,
There are many reasons for this situation. Let's do some troubleshooting to narrow down the scope of the problem.
According to your description, the batch can run successfully on the work PC, which means that there is no problem with the batch, the SharePoint site, and the account verification. Then there should be a problem with other settings of the server running the batch. Please check the following:
1, Network Configuration:
Network Connection: Check whether the network connection of the server is normal.
Firewall/Proxy Changes: Ensure there haven't been any recent changes to your network firewall or proxy settings that could be blocking access to SharePoint Online.
2, PowerShell Module Versions:
Module Updates: Ensure that your PowerShell modules for SharePoint Online are up to date.
3, TLS/SSL Protocols:
TLS Version: SharePoint Online requires TLS 1.2. Ensure that your server is configured to use TLS 1.2. You can add the following code at the beginning of your script to enforce TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
4, Windows Updates: Make sure your server has the latest updates installed. Sometimes, Windows Server component updates can affect network connectivity and protocols.
5, Logs: Review the Windows Event Viewer logs around the time when the error occurs. Network-related or .NET framework-related issues might be logged there.
Reference:
Hope this can help.
If the answer is helpful, please click "Accept as Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.