-3

I want to copy the csv files from two different servers and then paste those files at some location on 3rd server.

CSV File location on 1st server is - E:\HC_Disk\Sample\"+"DiskSpace-"+(Get-Date -format yyyyMMdd)+".csv

CSV file location on 2nd server - E:\HC_Disk\Sample\"+"DiskSpace-"+(Get-Date -format yyyyMMdd)+".csv

I have the script which generates the files everyday. My main concern is to club the two files together in the powershell.

Can you please help me with that. Thanks

3
  • 1
    Is this a request to create a code for you or there is your code which is not working properly? If the latter, please share it
    – maoizm
    Apr 17, 2018 at 1:23
  • I have not written any code for it so far. If you have any, please share it with me. Thanks! Apr 17, 2018 at 19:40
  • When I use the Robocopy command : robocopy \\ServerA\E:\HC_Disk\Sample\"+"DiskSpace-"+(Get-Date-format yyyyMMdd)+".csv\ \\ServerB\E:\Test\ I'll get the error as invalid parameter "-format". Could you please suggest on this? Apr 17, 2018 at 23:38

1 Answer 1

0

If you're referring to merging two CSVs, assuming the same headers, try below (modify for your filenames/paths):

Get-Content file1.csv, file2.csv | Select-Object -Unique | Set-Content mergedfile.csv
3
  • Thanks for the answer. My headers are same in both the files. Also if I have to copy the above two files from two different servers to the 3rd server, how can we use ROBOCOPY for that? Apr 17, 2018 at 22:26
  • 1
    @HaninderCheema Have you made any effort at all to solve this yourself?
    – EBGreen
    Apr 18, 2018 at 12:20
  • Copying files from one system to another system is a basic and thoroughly documented process that can be achieved using a plethora of methods, all of which can be found via Google. Combining the files after copying can be achieved using the code I posted above via PowerShell, or another method if you prefer.
    – bentek
    Apr 18, 2018 at 19:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .