The path \\client\s$
is mapped only in the user session context.
Running your script as any other user, or otherwise outside the user's session, means the path won't be reachable, and your script will fail.
Try and configure the task to run as the same user that is logged on to the Windows machine and select Run only when user is logged on. As far as I remember, that should cause the task to run in the user's session.
I'm not sure if Run with highest privileges will cause the script to run in a different session, but you can try it out if you need script to run elevated.