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

JBark
Tera Expert

What account are using to perform the task? D$ is a default admin share, so the account would have to be a local admin on both the MID server host and the server you're copying from.


As my original post says, the credential vault has an account that is a local admin on both servers.


Community Alums
Not applicable

Hi James,


I know it sounds basic, but I would verify that you can reach \\server1\$d\reports\ from the MID Server that is used by the activity. This may not be the same one you have indicated as the destination. You can verify in the ECC Queue. If a different MID Server is being used that cannot reach that server for some reason, that could be the issue. That's the first thing that comes to mind.


Ben


Antony_Alldis
ServiceNow Employee
ServiceNow Employee

Hi James,



I would use the Test-Path PowerShell cmdlet to establish that you can actually reach the files/folders.



I would do a 2 x way check....



1) Login to the "source" host (server1), and use Test-Path to see if the Destination folder \\server2\d$\reports is available


2) Login to the "target" host (server2), and use Test-Path to see if you can see the source file: \\server1\d$\reports\test.txt



More details on how this is used in Microsoft Developer Network: Test-Path



Hope this helps!



All the best,


Tony Alldis




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