Automation

 View Only
  • 1.  $_.Extensiondata Help Please

    Posted Nov 08, 2011 06:26 AM

    Hi All

    I understand that the above will dig deeper in getting more info from a Vsphere object point of view. What I do not understand is how do you get to all the properties/methods or whatever you wanna call it, for example, how do you know all the options available to you from the Extensiondata object, is there some sort of "Get-Member" to see all the properties and methods you can string together ?

    $_.Extensiondata.Summary.Config.Product.Build
    $_.Extensiondata.Summary.Hardware.CpuMode
    $_.Extensiondata.Config.Product.Name

    So looking at the above, how do I find ALL the bits i can tag on the back of Extensiondata like the bold items as shown

    Many thanks - and apologies if it does not make sense at all. :-)

    Cheers !



  • 2.  RE: $_.Extensiondata Help Please

    Posted Nov 08, 2011 06:56 AM

    Hi,

    You can use Get-Member to see both the properties and methods:

    $_.ExtensionData | Get-Member

    $_.ExtensionData.Summary | Get-Member

    You can aso use the VIM API reference - just check the type of extension data and look it up in the reference:

    $_.ExtensionData.GetType().Name

    http://pubs.vmware.com/vsphere-50/index.jsp?topic=/com.vmware.wssdk.apiref.doc_50/right-pane.html

    Regards,

    Dimitar



  • 3.  RE: $_.Extensiondata Help Please

    Posted Nov 08, 2011 07:33 AM

    Besides the Get-Member cmdlet and the SDK documentation there is also another cmdlet you can use: Format-Custom. This cmdlet will not only give you the property names, but it will give you the property values as well. E.g.

    $_.ExtensionData | Format-Custom -Depth 1


    If you increase the depth level, you will get more levels at once. But the cmdlet also takes longer to complete.



  • 4.  RE: $_.Extensiondata Help Please

    Posted Nov 08, 2011 07:49 AM

    Excellent guys ! Thanks so much !



  • 5.  RE: $_.Extensiondata Help Please

    Posted Nov 08, 2011 09:17 AM

    Oops - spoke too soon - maybe I'm just doing something wrong :

    If I type $_.Extensiondata | Get-Member

    I get  :

    Get-Member : No object has been specified to the get-member cmdlet.
    At line:1 char:30
    + $_.ExtensionData | Get-Member <<<<
        + CategoryInfo          : CloseError: (:) [Get-Member], InvalidOperationException
        + FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand

    I assume that it is looking for an object in $_  which is empty

    Thanks



  • 6.  RE: $_.Extensiondata Help Please
    Best Answer

    Posted Nov 08, 2011 09:20 AM

    You should of course have something in $_

    Get-VMHost MyEsx | %{$_.ExtensionData | gm}

    The $_ variable represents the object that was passed through the pipeline.

    In the example above the VMHostImpl object.



  • 7.  RE: $_.Extensiondata Help Please

    Posted Nov 08, 2011 09:30 AM

    Thought so - working fine now.... Thanks LucD !