VMware Cloud Community
mmustafa_
Contributor
Contributor

Get-VM select Customfields, Name from PowerCLI

Hi,

I need to select Virtual Machine's custom attributes from PowerCLI but i couldn't found correct commands. How can i get following "CI" attribute from PowerCLI?

CustomField.jpg

Regards,

Mustafa

7 Replies
SupreetK
Commander
Commander

For a VM with the name Test-1, you can get the custom fields using the below command -

Get-VM -Name Test-1 | ft CustomFields

Or run <Get-VM -Name Test-1 | fl *> to get the complete details of the VM.

Please consider marking this answer as "correct" or "helpful" if you think your questions have been answered.

Cheers,

Supreet

0 Kudos
mmustafa_
Contributor
Contributor

I need to all of virtual machines custom attributes (for example all "CI") list.

0 Kudos
SupreetK
Commander
Commander

You can use the below command to get the custom fields for all the VMs in the vCenter -

Get-VM | ft Name, CustomFields

Export to .csv file - Get-VM | ft Name, CustomFields | Export-CSV VMs-CustomFields.csv -NoTypeInformation

Please consider marking this answer as "correct" or "helpful" if you think your questions have been answered.

Cheers,

Supreet

0 Kudos
mmustafa_
Contributor
Contributor

You can see query results on the following screenshot. I don't understand report results? I need to custom field "CI" (You can see my first screenshot ) under the annotations.

Customfields.jpg

0 Kudos
SupreetK
Commander
Commander

Can you just run <Get-VM | ft Name, CustomFields> and share the output for a few VMs?

Cheers,

Supreet

0 Kudos
mmustafa_
Contributor
Contributor

I can get all of CI value list with following command.

get-vm | get-annotation -customattribute "CI" | select annotatedentity, name, value,uid, ExtensionData, Client | Export-Csv C:\test.csv -Force -NoTypeInformation

sanjaygpt171
Enthusiast
Enthusiast

Ho we cam get values for particular filed like i want only value of Department and use case filed. The command is showing all the values of custom attributes

0 Kudos