any idea how this key is configured or set for each vm?
(get-vm xxx | get-view).CustomValue.Key
These are the keys assigned by the CustomFieldsManager to the Custom Attributes in your environment.
On the VM under CustomValue, the system stores the Key and the Value, if there is one, of all Custom Attributes for that specific type of object (VirtualMachine in this case).
With the Get-CustomAttribute cmdlet, you can retrieve the Key of each Custom Attribute
Some sample code
$vmName = 'MyVM'
$vm = Get-VM -Name $vmName
Get-Annotation -Entity $vm |
ForEach-Object -Process {
$ca = Get-CustomAttribute -Name $_.Name
New-Object -TypeName PSObject -Property ([ordered]@{
VM = $vm.Name
CA = $ca.Name
CAKey = $ca.Key
Value = $_.Value
})
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc. But under custom attributes of the Vm, I do not see they Key.
I only see Attriute, Value and Type
from powercli, I go
Get-CustomAttribute -TargetType VirtualMachine | ft -auto
Key Name TargetType
--- ---- ----------
Then I see the key, name and Target type. Would these be set globally
Yes, they are done on the level of the VCSA.
See the CustomFieldManager for some more info.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference