Hello, I am trying to understand the meaning of the CustomFields value on virtualmachines, I have searched the web after an explanation of what I can use this field for and havent found anything that explains it, only a bounch of useful scripts that uses customfields with example whocreatedaVM etc.
The reason that I want to get this explained to me is that the only key we have in our CustomField is a
Here is an example:
PowerState : PoweredOn
Description :
Notes :
Guest : VMware.VimAutomation.Client20.VMGuestImpl
NumCpu : 1
MemoryMB : 1024
HardDisks : {Hard disk 1}
NetworkAdapters : {Network adapter 1}
UsbDevices : {}
CDDrives : {CD/DVD Drive 1}
FloppyDrives : {Floppy drive 1}
Host : HOST26
HostId : HostSystem-host-6827
VMHostId : HostSystem-host-6827
FolderId : Folder-group-v22
ResourcePoolId : ResourcePool-resgroup-780
DatastoreIdList : {Datastore-datastore-52252}
HARestartPriority : ClusterRestartPriority
HAIsolationResponse : AsSpecifiedByCluster
DrsAutomationLevel : AsSpecifiedByCluster
VMSwapfilePolicy : Inherit
CustomFields : {[http://system.service.vmware.vsla.stagemanager.domain.se, |http://system.service.vmware.vsla.stagemanager.domain.se, ]}
Id : VirtualMachine-vm-52974
Name : vm-dc03
How can I use/update the custom fields on our VM:s? And why have our stagemanager server updated the customfield on the more part of our VMs? A note here is that we do not use stagemanger anymore, so the stagemanager.domain.se is no longer available..
Is there any documentation that explain the usage of CustomFields?
BR
In short, a custom field is a new attribute or property that you can assign to specific entities (guests, hosts, folders...) in your vSphere environment.
There are several cmdlets that let you manipulate custom fields.
To create a new custom field for specific entities use the New-CustomAttribute or New-CustomField cmdlets.
Both have practically the same functionality but the latter also allows you to specify a value in one go.
The Set-CustomAttribute allows you to rename an existing custom field, the Set-CustomField allows you to assign a new value to an existing custom field.
The function of the Remove-CustomAttribute and Remove-CustomField cmdlets should be obvious.
When you get an entity, PowerCLI includes a hash array with all the custom fields and their values for that custom field.
You can extract the value of the custom field like you would with a regular hash array.
$vm = Get-VM myVM $vm.CustomFields # Will return the value of the custom field named Field1
Note that the square brackets will probably not display correctly due the forum SW.
But it should say "$vm.CustomFields " without the blanks.
To remove the remnant that you see in your environment you could do
Remove-CustomField -Entity VM -Name "vsla"
Provided I interpreted the name of the field correctly
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
In short, a custom field is a new attribute or property that you can assign to specific entities (guests, hosts, folders...) in your vSphere environment.
There are several cmdlets that let you manipulate custom fields.
To create a new custom field for specific entities use the New-CustomAttribute or New-CustomField cmdlets.
Both have practically the same functionality but the latter also allows you to specify a value in one go.
The Set-CustomAttribute allows you to rename an existing custom field, the Set-CustomField allows you to assign a new value to an existing custom field.
The function of the Remove-CustomAttribute and Remove-CustomField cmdlets should be obvious.
When you get an entity, PowerCLI includes a hash array with all the custom fields and their values for that custom field.
You can extract the value of the custom field like you would with a regular hash array.
$vm = Get-VM myVM $vm.CustomFields # Will return the value of the custom field named Field1
Note that the square brackets will probably not display correctly due the forum SW.
But it should say "$vm.CustomFields " without the blanks.
To remove the remnant that you see in your environment you could do
Remove-CustomField -Entity VM -Name "vsla"
Provided I interpreted the name of the field correctly
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello,
thank you for the reply. I was a little uncertain why we had a customfield value with that name and if there was any problem with removing an already specified customfield value.
Is there any document or something that explains or give some example on how to use this function?
There is Hal's book which explains all cmdlets (up to VI Toolkit 1.5) in more detail (with examples) than the PowerCLI Reference does.
And in a couple of months there will be our (Alan,Glenn,Jonathan,Arnim and me) book.
Already on pre-order.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Well, thanks again for a quick and helpful answer.
Signing up for a pre-order on that one.
Thanks, have a nice day.
Great, will this custom field survive a host reboot or removal/addition of host to vCenter ?
In previous versions, i noticed the custom field is lost when re-adding to vCenter.
These custom fields are kept in the vCenter DB.
I'm afraid the link between a custom field and a host is gone when you remove/add the host from/to vCenter.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yeah, thought so....so what can we do to create permanent stamps on hosts that provisioning teams move between various vCenters based on needs ?
Basically looking for a way to tag a host, with a internal build versioning code.
I see the problem, but I'm afraid I don't have a real solution for this.
You could place something on the ESX(i) server itself, but that would be cumbersome (plink.exe or pscp.exe) and most probably not supported.
Now if you could get at the server Asset-tag, you would have a key through which you can store your information in an external database.
But unfortunately, the Asset-tag is not retrievable on all types of HW
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference