Export VM notes

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of fair64 fair64 2 years, 3 months ago.

  • Author
    Posts
  • #18728
    Profile photo of fair64
    fair64
    Participant

    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
    }

    Thanks
    Andy

  • #18729
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Why wouldn't...

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

    Work?

  • #18731
    Profile photo of fair64
    fair64
    Participant

    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..

  • #18732
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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.

  • #18733
    Profile photo of fair64
    fair64
    Participant

    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.

    Thanks
    Andy

You must be logged in to reply to this topic.