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