A previous VMWare admin had set annotations on all of our VMs. No one has maintained these annotations since then and the info is now out of date and confusing. So what I want to do is clear all of these out. Can someone comeup with a powercli script that would delete all custom attributes and annotations for VMs in my vCenter?
Regards,
Michael
Would this do the trick?
Get-CustomAttribute | Remove-CustomAttribute -Confirm:$false
Get-VM | Set-Annotation -Notes '' -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
the command
Get-VM | Set-Annotation -Notes '' -Confirm:$false
isn't working on our Systems. we have vCenter 6.5.
Best regards
Try with the following (in the more recent PowerCLI versions, the Set-Annotation cmdlet doesn't have a Notes parameter)
Get-VM | Set-VM -Notes '' -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Okay, this works fine but i have a other problem.
We are using Citrix to deploy virtual machine on the esx.
Citrix create a custom Attribute with the Name "XdConfig" and the value "XdProvisioned=true" on the vm.
i want to know, how delete the custom Attribute on the virtual machine?
Can you try with
Get-CustomAttribute -Name XdConfig -TargetType VirtualMachine |
Remove-CustomAttribute -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
thank you very much for the quick Response.
But i wont to delete the global Attribute on the Host/vCenter.
There is a custom Attribute on the virtual machine.
If i use the powershell command:
(get-vm -Name "NameOfTheVM").ExtensionData.AvailableField
i become the value:
Key : 408
Name : XdConfig
Type : string
ManagedObjectType : VirtualMachine
FieldDefPrivileges :
FieldInstancePrivileges :
DynamicType :
DynamicProperty :
How to delete this custom field on the vm?
Thank for your Response.
If you define a Custom Attribute of the type VirtualMachine, each VM will have this Custom Attribute.
You have 2 options:
$ca = Get-CustomAttribute -Name Test2 -TargetType VirtualMachine
Get-VM -Name MyVM | Get-Annotation -CustomAttribute $ca | Set-Annotation -Value '' -Confirm:$false
You can not remove a Custom Attribute on a single VM, only change its value.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
thank you very much.
This Reply solved my Issue.