Hi all
I've created the following viproperty to tell me if a datastore is 'local' or 'SAN' based. It 'seems' to be working however I thought I would get a second opinion from you guys
New-VIProperty -ObjectType Datastore -Name _LOCALorSAN -ValueFromExtensionProperty 'info.vmfs.local' -Force
When i call up a SAN datastore and ask to see its properties its shows up fine and reports that it is NOT local. However when I ask to see a 'local' datastore it still shows that it is TRUE (which is correct) but shows an error (see below).
Get-Datastore : 18/01/2014 17:18:45 | Get-Datastore | InvalidProperty(info.vmfs.local): |
At line:1 char:1
+ Get-Datastore *7641* | fl *
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo | : NotSpecified: (:) [Get-Datastore], InvalidProperty | |
+ FullyQualifiedErrorId : Client20_ExtensionDataHelper_GetExtensionDataByObjectContent_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetDatastore |
Have i done something wrong ?
Thanks in advance
Munster
I don't know why your command does not work because it looks right to me. You can use the following alternative:
New-VIProperty -Name _LOCALorSAN -ObjectType Datastore `
-Value {
param($ds)
$ds.ExtensionData.Info.Vmfs.Local
} -Force
This is because the Info.Vmfs.Local property is not present for all derived Datastore objects.
In Vitali's post called Ability to customize VI objects, it says (and I quote) :
" Because SDK objects are hierarchical related it is possible to define custom property
on ancestor type and all its inheritors will have the property too."
If we look at a sample new property on the datastore object, we can demonstrate this behavior.
The new property is not only present on the Datastore object, but also on the derived ones !
My advise, if you need to define a new property, that is based on a subset of the object, in other words not present in all derivatives of the object, do it with a script block, not with the ValueFromExtensionProperty option.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference