clavelstephane
Enthusiast
Enthusiast

Delete vCloud Director related Custom Attribute on a VM

Hello

Following Tomas Fojta's blog post

How to Export Running VM from vCloud Director – Tom Fojta's Blog

I'm looking for a way to automate step 4: Remove vCloud Director related Custom Attribute on a set of powered on VMs

I gave a try with powerCLI, this gives the below error to me, whether the VM is powered on or off by the way.

PowerCLI E:\LabShare\Scripts> $vm.CustomFields.remove(“system.service.vmware.vsla.fraise”)

Exception calling “Remove” with “1” argument(s): “Cannot remove value from a
read-only dictionary.”
At line:1 char:1
+ $vm.CustomFields.remove(“system.service.vmware.vsla.fraise”)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException

Help welcome !

thanks

0 Kudos
3 Replies
RvdNieuwendijk
Leadership
Leadership

You can use the Set-Annotation cmdlet to clear the value of the custom field with the following PowerCLI command:

Set-Annotation -Entity $vm -CustomAttribute 'system.service.vmware.vsla.fraise' -Value ''

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
clavelstephane
Enthusiast
Enthusiast

Thanks

You're correct but what I'm trying here is not to clear the value of the custom attribute, but remove it.

0 Kudos
vinny95
Contributor
Contributor

Has someone found out how to remove a custom attribute from a VM ?

vinny

0 Kudos