Copy file from Server to MID server

james_lewis
Tera Contributor

I am trying to copy a file or directory from a Windows server to my Windows MID server.   Using a simple Powershell activity where the credential vault has an account that is a local admin on both servers.

        Copy-Item   -path \\server1\d$\reports\test.txt   -destination   \\server2\d$\reports\test.txt   -verbose   -credential $cred

yields this error altho I know the file is there.

        Copy-Item : Cannot find path '\\server1\d$\reports\' because it does not exist.

I have struggled with this a lot and wonder if someone can help me out.

11 REPLIES 11

The problem seems to be that the credential being used is the one the MID service is running under.   When I run the MID service under a local admin account that exists on both servers, the copy-item completes as expected.   The -credential parameter does not seem to be used.   I see that a credential affinity to the source server has been established.   I found a post that says the same thing the wiki says that the MID service account is used if there isn't one in the credentials vault that will work.   Any ideas what I might be doing wrong?


Hello James,



On your Windows credential, is it active and configured to 'applies to' all MID servers or only specific ones?



find_real_file.png


Yes.     And a discovery against the source server completes successfully with the credentials I am trying to use.


Hi James,



Can you confirm if the "source server" is the same server that the MID server is actually installed on?



Normally the "credential" passed is used against the "target" (*where the file should eventually end up) not the "source" (*where the file exists currently).



Your example:



        Copy-Item   -path \\server1\d$\reports\test.txt   -destination   \\server2\d$\reports\test.txt   -verbose   -credential $cred



Appears to indicate that there are 2 x servers involved, rather that a "local" file system. Do both server1 and server2 share the same credential?



If this is going to be a regular function for you, have you thought about using a file share?



Does Robocopy yield any different results?



All the best,


Tony Alldis



*Please mark this Post as: Helpful, Like, or Correct Answer if applicable.


The destination server is the MID server.   As I posted on Aug 15, 2016 8:57 AM it seems that the -credential $cred parameter is not being used.   The credential is an entry in the credential table for a local admin account on both servers.   When I run the MID service under this account, the copy-items works as expected.