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; DynamicOps.ManagementModel.ManagementModelEntities PS > $h = $m.Hosts |? HostName -eq 'vCenterResources'; PS > $h.GetType().FullName; DynamicOps.ManagementModel.Host PS > $hp = $m.LoadProperty($h, 'HostProperties') | Select-Object PropertyName, PropertyValue; PS > $Location = ($hp |? PropertyName -eq 'Vrm.DataCenter.Location') .PropertyValue; PS > $Location PremiumSite1