0

TLDR: I need to move a large file from a server to the desktop of multiple SELECT machines connected to it.

Network topography:

  • 1 Server
  • 5 - 20 Connected PCs

This topography is pretty standard across all remote networks that I work on. On some occasions, I have to put files on each machine on a network; sometimes only on a few individual machines that site admins utilize.

I keep a 'master copy' of the file on the server at all times, and currently RDPing into each machine i need it on (once I resolve the IP to make sure they aren't printers/tablets/phones/etc...) and copy over the file where I need it from the server to the connected machine (the directory is standard). After researching, I think a PS script would probably work for what I need but I only know enough to be dangerous.

I use the following to resolve IPs to host names so I can determine which machines I need to put it on:

@echo off setlocal EnableDelayedExpansion set "xNext=" set "xComputer=" for /f %%A in ('net view /all') do ( set "xComputer=%%~A" if "!xComputer:~0,2!"=="\\" for /f "tokens=2,* delims=. " %%X in ('nslookup %%A') do ( if "!xNext!"=="1" ( echo.!xComputer! = %%X.%%Y set "xNext=0" ) if "!xComputer:~2!"=="%%~X" set "xNext=1" ) ) endlocal pause 

I want the ability to use the output of this code to build a list of IPs, then FTP the file to the IPs to a common directory C:/Folder . I could build a ComputerList.txt with the IPs and use it but I'm not quite sure how to integrate it.

2 Answers 2

0

If you're just needing to copy a file locally you don't need FTP, you can use a copy command (copy, xcopy, robocopy). Create a powershell array from your objects, then use the foreach cmdlet and use robocopy to copy the file to each of the workstations. Something line like:

Get-Content c:\machines_List.txt | Foreach-Object {robocopy c:\source \\$_\c$\folder filename.exe"} 
2
  • Assuming they are domain joined Commented Aug 16, 2018 at 11:19
  • This worked beautifully! Exactly what i was needing. Thank you! Commented Aug 16, 2018 at 13:24
1

Thankfully you don't need to recreate the wheel here. Use WinSCP. Here's the link to the documentation:

WinSCP - Using from PowerShell

If you need assistance after looking at this documentation, let me know by leaving a comment.

1
  • I got this to work for one machine at a time, I couldnt quite figure out how to add a list of IPs to push the file across the network all at once Commented Aug 16, 2018 at 13:25

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.