The VMware platform on which we now work with hypervisor.fr has several specific aspects and one of them is having a lot of custom fields.
Besides wanting consistency in all these custom fields, we like to have a “clean” production platform and therefore it is preferable to have a “N/A” custom field instead of a empty one (to avoid custom alerts), and avoiding oversights in OVF appliance deployment (which does not fill fields automatically).
So we developed a PowerCLI script which will replicate, if needed, custom fields and annotation from one VM to another in order to make your life easier, and mainly to avoid potential errors with manual input. You can also use it to fill up the VM’s custom fields with “N/A” (if parameter vmSourceName isn’t used).
The script takes the following arguments :
- vmSourceName (optional) : Name of the VM used for source replication
- vmDestinationName : Name of the VM used for destination replication
- force (optional) : This switch allows you to overwrite destination custom field
First of all, there is some checks in order to verify the source and destination VM exists:
Then comes the replication of custom fields and annotation. If destination’s VM already has some filled custom field, they will not be overwritten except if you’re using the -force switch:
Here are some example:
C:\foo>.\Set-Tags.ps1 -vmSourceName VM01 -vmDestinationName VM02
This will replicate custom field from VM01 to VM02 (without overwriting destination).
C:\foo>.\Set-Tags.ps1 -vmSourceName VM01 -vmDestinationName VM02 -force
This will replicate custom field from VM01 to VM02 (with overwriting destination).
C:\foo> .\Set-Tags.ps1 -vmDestinationName VM02
Fill custom field from VM02 with “N/A” string (without overwriting destination).
C:\foo> .\Set-Tags.ps1 -vmDestinationName VM02 -force
Fill custom field from VM02 with “N/A” string (with overwriting destination).
And as always, you can use Get-Help in order to get online help for the cmdlet: