VMware Cloud Community
brittonv
Contributor
Contributor

Get Custom Notes from VMWare and Power CLI

Greetings,

I need to get a list of all VM's

from my vCenter infrastructure.

I tried the get-vm Powershell but

it didn't get my custom fields properly.

How can I get a list of

all VM's on my Servers including my custom (Notes, Dev Status, Bus

Owner) fields?

If it matters I am exporting it to a CSV file.

Furthermore,

how can I edit that CSV file and then upload the changes to my ESX's

Reply
0 Kudos
4 Replies
ep4p
Enthusiast
Enthusiast

You need to create an SQL query against the VPX_VM table in your vCenter DB.

Reply
0 Kudos
brittonv
Contributor
Contributor

Can you point me to a resource that would explain how to do that?

Reply
0 Kudos
ep4p
Enthusiast
Enthusiast

The most basic way is to use sqlcmd command line on SQL server. Run something like: sqlcm -S <ServerName> -d <DB Name> -E and once prompted run SQL queries (ex. select DNS_NAME,GUEST_STATE from VPX_VM).

Reply
0 Kudos
LucD
Leadership
Leadership

You can use the Get-Annotation cmdlet for that.

Since I'm not sure in which format you want this listing I just wrote the values to the screen

foreach($vm in (Get-VM)){
	$vm | Get-Annotation | %{
		Write-Host $vm.Name $_.Name $_.Value
	}
}

Let me know if you want another output format.

____________

Blog: LucD notes

Twitter: lucd22


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

Reply
0 Kudos