Initiate a Remote File Transfer Process from Another Computer

This topic contains 4 replies, has 4 voices, and was last updated by  Laurent Maene 2 days, 20 hours ago.

  • Author
    Posts
  • #82009

    cyborgcommando
    Participant

    I have a scenario I'm trying to work out in my mind and I'm struggling to find a way to make it work using PowerShell and I'm not sure I have all the pieces in my mind. I want to send a command to another computer and have it retrieve files from a different computer. So something like this:

    A ↦ B ↔ C

    Computer A sends the command/code/session/job and all necessary information to Computer B.

    Ideally, Computer A disconnects and isn't necessary for any further part and shouldn't be involved in the file transfer.

    Computer B reaches out to Computer C and retrieves the files specified by any method.

    I'm really not sure where to concentrate my thoughts on this. I'd like to do this with a PSSession but it also seems like its possible to do this as a job but I'm not familiar with jobs and only partially familiar with PSSessions.

    What are some of the prerequesites I need to make a script like this work and what do you think is the best way to do this?

    I am running this from Windows 10 and PowerShell v5.1

    Thank You

  • #82021

    js
    Participant

    Do you know about copy-item and -fromsession and -tosession options?

  • #82024

    TommyQuality
    Participant

    Hi,

    1 way would be just to have a script on computer B that does everything it requires. You then just execute the script using

    invoke-command -ComputerName 'Computer B' -filepath C:\TheScript.ps1

    from Computer A?

    • #82063

      cyborgcommando
      Participant

      Hey Tommy,

      I'd like for the process to pass on the variables I pick (computernames and usernames, etc). Any clue how to pass that easily?

  • #82189

    Laurent Maene
    Participant

    Hello, maybe this can help,

    New-PSDrive -name "destination" -PSProvider FileSystem -Root "\\$computer\..." -Credential $cred
    Copy-Item '\\$source\...' -Destination "destination:\..." -Recurse
    Remove-PSDrive -name "destination"

    BR
    Laurent.

You must be logged in to reply to this topic.