The attributes can't be accessed directly (afaik) but by getting the virtualmachine object you can access and test the attributes.
In the virtualmachine object there are 2 arrays:
- AvailableField: contains all the available custom attributes. Here we have to get the "key" of the attribute we want
- CustomValue: contains all the values for the custom attributes. We have to use the "key" to find the desired value
The following script shows how this can be done from within the VI Toolkit
$VCimpl = Get-VIServer -Server <VCserver>
$tgtVM = "VMName"
$tgtName = "ReleaseSnapshot"
$tgtValue = "yes"
$vm = Get-View (Get-VM -Name $tgtVM).ID
foreach ($fld in $vm.AvailableField){
if ($fld.Name -eq $tgtName) {
$tgt = $fld.Key
}
}
foreach ($val in $vm.CustomValue){
if ($val.Key -eq $tgt){
if ($val.Valye -eq $tgtValue){
$retValue = $TRUE
}
}
}
You could package this logic in a function that you can then use inside a pipe-construct.