VMware Cloud Community
tdubb123
Expert
Expert

how is this key set ?

any idea how this key is configured or set for each vm?

(get-vm xxx | get-view).CustomValue.Key

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

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

Reply
0 Kudos
tdubb123
Expert
Expert

Thanks Luc. But under custom attributes of the Vm, I do not see they Key.

I only see Attriute, Value and Type

Reply
0 Kudos
tdubb123
Expert
Expert

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

Reply
0 Kudos
LucD
Leadership
Leadership

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

Reply
0 Kudos