1

I am trying to get a custom attribute value for my datastore, but bumping into an issue with type incompatibility. Is there anything I am doing wrong below, and how to fix it?

PowerCLI C:\> $ds = Get-Datastore -Name YK PowerCLI C:\> $ds Name FreeSpaceGB CapacityGB ---- ----------- ---------- YK 14,528.467 14,901.750 PowerCLI C:\> Get-Annotation -Entity $ds -CustomAttribute ykcustattr_global Get-Annotation : Cannot bind parameter 'Entity'. Cannot convert the "YK" value of type "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.VmfsDatastoreImpl" to type "VMware.VimAutomation.ViCore.Types.V1.Inventory.InventoryItem". At line:1 char:24 + Get-Annotation -Entity $ds -CustomAttribute ykcustattr_global + ~~~ + CategoryInfo : InvalidArgument: (:) [Get-Annotation], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetAnnotation 

Note 1: I am able to get a custom attribute for a virtual machine, cluster and host. The problem is with the Datastore only.

Note 2: I guess the problem is that Get-Datastore returns Datastore object, while Get-Annotation expects InventoryItem object for -Entity. It is not clear if it is possible to do a cast/transformation or anything like that.

VMware vCenter version: 6.5

Thank you!

1 Answer 1

0

I got an answer on the VMware forum and decided to post it here. Briefly, the problem exists, but there is a workaround:

https://communities.vmware.com/message/2826274#2826274

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.