You can create a custom property by writing a script and providing a name for the property. The script evaluates when the custom property is called for the first time.
Prerequisites
Verify that you are connected
to a
vCenter
Server
system.
Procedure
1 | Create a new custom property named NameOfHost that stores the name of the host on which a virtual machine resides. New-VIProperty -Name NameOfHost -ObjectType VirtualMachine -Value { return $args[0].VMHost.Name }
|
2 | View the NameOfHost properties of the available virtual machines. Get-VM | select Name, NameOfHost | Format-Table -AutoSize
|
You created a custom script property named NameOfHost for VirtualMachine objects.