Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 229203

How to add export-csv in this simple script?

$
0
0

Hi,

 

Thanks for lot of scripts here.

 

Here is the script to collect vms list and cluster information. I have the list of vms as a excel file (csv file). So i tried like this

 

$vms = import-csv c:\scripts\vms.csv

foreach ($vmname in $vms)

{

get-vm $vmname.name | Select Name,@{N="cluster";E={Get-cluster -VM $_}}

} |

Export-Csv -NoTypeInformation -useculture C:\scripts\vminfo1.csv


In the excel sheet Name column for the VMs name.

 

But when i tried with export-csv here, I am getting the error

[vSphere PowerCLI] C:\scripts> .\Clusterdetailswithimport-csv.ps1

An empty pipe element is not allowed.

At C:\scripts\Clusterdetailswithimport-csv.ps1:6 char:3

+ }| <<<<

    + CategoryInfo          : ParserError: (:) [], ParseException

    + FullyQualifiedErrorId : EmptyPipeElement

 

Could someone help me, what's wrong adding export-csv here? Without export-csv the output is "OK"


Viewing all articles
Browse latest Browse all 229203

Trending Articles