Initiate a Remote File Transfer Process from Another Computer

Welcome Forums General PowerShell Q&A Initiate a Remote File Transfer Process from Another Computer

This topic contains 4 replies, has 4 voices, and was last updated by

 
Participant
1 year ago.

  • Author
    Posts
  • #82009

    Participant
    Points: 0
    Rank: Member

    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
    Points: 202
    Helping Hand
    Rank: Participant

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

  • #82024

    Participant
    Points: 0
    Rank: Member

    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

      Participant
      Points: 0
      Rank: Member

      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

    Participant
    Points: 23
    Rank: Member

    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.

The topic ‘Initiate a Remote File Transfer Process from Another Computer’ is closed to new replies.