VMware Cloud Community
esxi1979
Expert
Expert

export-csv gives only last row in foreach loop

$csv= import-csv c:\temp\test.csv

foreach ($line in $csv)

{

Get-View -ViewType VirtualMachine  -property @("Name","guest.HostName", "guest.GuestFullName") -Filter @{"Name"= $($line.vm) }|`

Select-object Name,

@{N="FQDN";E={$_.guest.HostName}},

@{N="OS ";E={$_.guest.GuestFullName}},

}

above works well

But i am not able to get this in csv i tried appending "| Export-Csv -NoTypeInformation -UseCulture c:\test.csv" but gives only last row ...

I asked this Q in past as well but sorry forgot the solution offered here .. some parameter like @ was used to make the loop as a single values but do not remember ... LucD i think you told me that ...

0 Kudos
1 Reply
esxi1979
Expert
Expert

I remember it now

call operator &

0 Kudos