Write and read custom attributes

In my previous article I described that how you can create Custom Attributes. If it created, and ready to use, you should read and write all virtual machine’ Custom Attributes via vSphere Client or PowerCLI.

In the vSphere Client you can modify the attributes in the Summary tab of the VM. You can find the Annotations section at left down.

read_write_1

Click on Edit. Here you can edit all attribute value, simply click on the Value field of the attribute. If you ready, click on OK.

read_write_2

To select each VM, and edit attributes one by one is a boring job, if you need to change a bundle of VM. The solution is automation with PowerCLI.

You should use the following command to write a Custom Attribute:

Get-VM –Name testsrv| Set-CustomField -name SAPnumber -Value “123456”

You should use the following command to read a Custom Attribute:

(Get-VM -Name testsrv).CustomFields

That’s all!

2 thoughts on “Write and read custom attributes”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s