Export VM notes

Trying to export the name and notes attached to all Virtual Machines in a vcenter. Is there a more effecient way of doing this other than this:

$VM = get-vm
foreach($v in $vm){
get-vm $vm | select name, notes | export-csv c:\vm-notes.csv


Why wouldn’t…

get-vm | select name, notes | export-csv c:\vm-notes.csv


Hi Don,
Well I tried that first but it would never finish running the script.
What I ended up doing and the only way I could get it to work without stalling on me was this:

Connect-VIServer vcenter01
Connect-VIServer vcenter1
$a = get-vm | select Name,Notes
$a | export-csv c:\vm-notes.csv

Not sure why it was stalling the other ways…

Me, either. It’s something you’d probably get a better answer for in VMware’s forums - there’s a lot more folks there who understand how their cmdlets communicate with their server.

Most likely because I was connected to two VCenters, your line of code works fine when connected to a single vcenter. Thanks again Don, always enjoy your tutorials out on the web, keep up the good work.