I have five CSV files. Each file has B, C, D, E columns.
I want to move these columns to a new file.
1.csv has B, C, D, E columns.
2.csv has B, C, D, E columns.
3.csv has B, C, D, E columns.
4.csv has B, C, D, E columns.
5.csv has B, C, D, E columns.
These columns must be copied to new file: 6.csv
I wrote the below script, but it is giving me error. Any help would be really good.
$source = "c:\temp\1.csv"
$dest = "C:\temp\6.csv"
$Excel = New-Object -ComObject Excel.Application
$Excel.visible = $false
$Workbooksource = $excel.Workbooks.open($source)
$Worksheetsource = $Workbooksource.WorkSheets.item("Bit")
$range = $Worksheetsource.Range("B1:C1:D1:E1").EntireColumn
$range.Copy() | out-null
$Workbookdest = $excel.Workbooks.open($dest)
$Worksheetdest = $Workbookdest.Worksheets.item("MergedwithHeader_Sample")
$Range = $Worksheetdest.Range("A1:B1:C1:D1")