This is great - I don't quite start off with two csv's though that I'm merging - what I've got is this:
### I start with one input file like this:
$report = @()
import-csv vmlist.csv -useculture | foreach{
$vmname = $_.vmname
$datacenter = $_.datacenter
$owner = $_.owner
$numcpu = (get-vm $vmname).numcpu
$properties = @{'vmname' = $vmname;
'datacenter' = $datacenter;
'owner' = $owner;
'numcpu' = $numcpu;
}
$object = New-Object -TypeName PSObject -Property $properties
$report += $object
}
$report | select vmname,datacenter,owner,numcpu | export-csv report.csv -useculture -notypeinformation
##so the goal is that if vmlist.csv has ANY other columns beside vmname, datacenter and owner, that the report.csv file that this report creates includes all those extra columns, whatever they might ##be. Each new vmlist.csv file always has the "vmname" column, so that I can count on - but they may have 5 - 40 other columns also, which I can't predict that need to be preserved.
## THanks!