I have a report the needs to import VM inventory data from multiple csv's then combine it into a single csv. All of the csv's are in one folder and nothing else is in that folder
If you look at the inputfiles, the format of the csv's that need to be imported are all exactly the same:
vmname,vcentername,application,hostname,OS,memorygb
thisvm1,thisvcenter,thisapplication,thishostname,windows,12
thatvm2,thatvcenter,thatapplication,thathostname,linux,8
How can I take multiple csvs in this same format, all in the the same folder, import them and then combine the results into one csv file?
Thanks!
Try something like this
$folder = 'C:\Data'
$result = 'C:\result.csv'
Get-ChildItem -Path $folder -Filter *.csv -File | %{
Import-Csv -Path $_.FullName -UseCulture | Export-Csv -Path $result -Append -NoTypeInformation -UseCulture
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
$folder = 'C:\Data'
$result = 'C:\result.csv'
Get-ChildItem -Path $folder -Filter *.csv -File | %{
Import-Csv -Path $_.FullName -UseCulture | Export-Csv -Path $result -Append -NoTypeInformation -UseCulture
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK thanks again.