VMware Cloud Community
kbhowmick123
Enthusiast
Enthusiast

Error while trying to fetch VM's Notes description for all the VM using powercli.

Hello,

I have the below script running, however when ever I'm trying to add the nodes field it's not working.

Get-VM | Sort-Object -property Name | Get-View -Property @("Name", "Guest.GuestFullName", "Guest.IPAddress", "VM.Notes") | Select -Property Name, @{N="Running-OS";E={$_.Guest.GuestFullName}},@{N="ip",E={$_.Guest.IPAddress -join '|'}}N,"notes descrp";E={$_.Guest.VM.Notes}} | Export-Csv -Path c:\temp\report.csv

When I'm adding notes I'm getting error.

Can some one help me on this.

0 Kudos
4 Replies
jpsider
Expert
Expert

'VM.Notes ' - is not a valid property do you have that information stored in an 'annotation' ?

0 Kudos
LucD
Leadership
Leadership

Since you are using Get-View, the calculated property should be

@{N='notes descrp';E={$_.Config.Annotation}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
qdljc
Contributor
Contributor

get-view is much faster than get-vm, there is not necessary to use get-vm

0 Kudos
jpsider
Expert
Expert

Correct, You can run this without Get-VM:

Get-View -ViewType VirtualMachine | Select-Object -Property Name, @{N="Running-OS";E={$_.Guest.GuestFullName}},@{N="ip";E={$_.Guest.IPAddress}},@{N="notes Desc";E={$_.Config.Annotation}} | Export-Csv -Path c:\temp\report.csv

Not sure what you were trying to accomplish with the  '-join'

0 Kudos