I created a simple PowerShell script that maps a shared folder, copies a file from the shared folder and closes the share.
The script should be executed on a Windows Server 2008 R2 server.
It looks like:
net use u: \\192.168.1.10\myshare /user:myusername mypassword /persistent:no >> Null
Copy-Item -Path "u:\myfile1.txt" -Destination "c:\myfolder" -force
net use u: /delete >> Null
If I execute it interactively it works fine.
If I schedule it as a scheduled task it does nothing.
So my questions are:
– What is the right way to map a shared folder from inside a scheduled task? I saw several pages in the web reporting problems, but I was unable to locate a Solution
– Given a PowerShell script scheduled as a scheduled task, how can I see the possible error messages while executing it?