Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Hi James,



What happens if you remove the "server" part from the "destination" i.e. make it a "local" file system?



As the command is being run on the MID server itself, you should not require the "server" in the command and can just specify the local file system.



From:


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



To something like:


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



Does that change the behaviour in any way?



Just wondering if by specifying 2 x servers in the command is causing the issue.



Is it possible to login to the MID server host using the credentials as used for "server1"?


Does an affinity record exist for the MID server host for the credentials you are using?



All the best,


Tony Alldis



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


By Default, Any command that is run on MidServer it uses MidServer Service Account, Unless MidServer Service Account is not part of the your domain accounts this will not work, The only way is to run the midServer using the domain account.