VMware Cloud Community
TheVMinator
Expert
Expert
Jump to solution

Combining VM inventory data

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!

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

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

TheVMinator
Expert
Expert
Jump to solution

OK thanks again.

0 Kudos