In vCAC you can set a location on a ‘Compute Resource’. While in some cases this might not make sense (e.g. vCenter stretched clusters) you might still want to use it, for example to implement some placement logic. When you have a look at the object, you might be surprised to see, that there is no attribute of the corresponding ‘Host’ object within the management model. The reason for this is, that this location field is actually implemented as a ‘HostProperty’ (although it is not visible in the GUI). Here is how you can read out that information via API:

PS > $m.GetType().FullName;
PS > $h = $m.Hosts |? HostName -eq 'vCenterResources';
PS > $h.GetType().FullName;
PS > $hp = $m.LoadProperty($h, 'HostProperties') | 
  Select-Object PropertyName, PropertyValue;
PS > $Location = 
  ($hp |? PropertyName -eq 'Vrm.DataCenter.Location')
PS > $Location

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.