If you're still writing custom PowerShell scripts for basic file transfers and Excel reports, you're working too hard. Ready-made PowerShell modules handle most common tasks better than anything ...
Microsoft's legacy Remote PowerShell protocol in the Security and Compliance PowerShell module will begin to be deprecated soon, starting from July 15, 2023 as a part of modernisation efforts.