0

Fail to copy file from one Windows machine M01 to other Windows machine M02.

Both machines are on AWS, on same region, same VPC, same subset. SSH and RDP port are open for both machines. Using PowerShell to copy (transfer) files.

Code:

Write-Host "Remote IP:" $record
$destinationpath = "\\$record\c$\installer.exe"
Write-Host "Destination:" $destinationpath 
Write-Host "Source:" $agent\installer.exe 
Invoke-Command -ScriptBlock {
    Copy-Item -Path $agent\installer.exe -Destination $destinationpath -Recurse
}

Error:

Remote IP: xx.x.x.xxx
Destination: \\xx.x.x.xxx\c$\installer.exe
Source: C:\Users\Administrator\Downloads\installer.exe

Copy-Item : The network path was not found
At C:\Users\Administrator\Downloads\agent_install_gui.ps1:117 char:30
+ ... criptBlock {Copy-Item -Path $agent\installer.exe -Destination $des ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand

I used to Test connection,

Fail in Test-Connection:

PS C:\Users\Administrator\Downloads\ce_Windows\ce_Windows> Test-Connection

cmdlet Test-Connection at command pipeline position 1
Supply values for the following parameters:
ComputerName[0]: xx.x.x.xxx
ComputerName[1]:
Test-Connection : Testing connection to computer 'xx.x.x.xxx' failed: Error due to lack of resources
At line:1 char:1
+ Test-Connection
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (xx.x.x.xxx:String) [Test-Connection], PingException
    + FullyQualifiedErrorId : TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand

Test-Connection : Testing connection to computer 'xx.x.x.xxx' failed: Error due to lack of resources
At line:1 char:1
+ Test-Connection
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (xx.x.x.xxx:String) [Test-Connection], PingException
    + FullyQualifiedErrorId : TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand

Test-Connection : Testing connection to computer 'xx.x.x.xxx' failed: Error due to lack of resources
At line:1 char:1
+ Test-Connection
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (xx.x.x.xxx:String) [Test-Connection], PingException
    + FullyQualifiedErrorId : TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand

Test-Connection : Testing connection to computer 'xx.x.x.xxx' failed: Error due to lack of resources
At line:1 char:1
+ Test-Connection
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (xx.x.x.xxx:String) [Test-Connection], PingException
    + FullyQualifiedErrorId : TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Vivek Sable
  • 9,938
  • 3
  • 40
  • 56
  • i THINK you are looking at the classic "double hop" problem. if so, a search wil show you the various workarounds. [*grin*] – Lee_Dailey Apr 15 '19 at 07:07
  • 1
    The immediate problem is scope (the variables inside and outside the scriptblock are not the same). The 2nd-hop-problem comes on top of that. – Ansgar Wiechers Apr 15 '19 at 08:15
  • @Lee_Dailey: you have any specific link from which this issue will fix. I am still trying. no luck yet. – Vivek Sable Apr 15 '19 at 08:16
  • @VivekSable - do a search for `powershell double hop` in your fave search engine and you should find several - look them over and pick the one that suits your needs. [*grin*] – Lee_Dailey Apr 15 '19 at 09:31

0 Answers0