2 Replies Latest reply on Oct 30, 2012 5:27 AM by Grzesiekk

    strange behaviour of get-viobjectbyview

    Grzesiekk Expert

      $a=get-vm testvm|get-view

      PowerCLI C:\> $a|Get-VIObjectByVIView
      Get-VIObjectByVIView : 10/30/2012 12:57:46 PM    Get-VIObjectByVIView        Object reference not set to an instance of an object.

       

      PowerCLI Version
      ----------------
         VMware vSphere PowerCLI 5.0.1 build 581491
      ---------------

       

      I think that this has worked previously :/

       

      PowerCLI C:\> $a.moref|Get-VIObjectByVIView

       

      Name                 PowerState Num CPUs Memory (MB)
      ----                 ---------- -------- -----------
      testvm               PoweredOff 1        4096

       

      When i pass moref directly to get-viobjectbyview then it executes without error. from help :

      -MORef <ManagedObjectReference[]>
          Specify the managed object ID, obtained from a property of another mana
          ged object or a view.

       

          Required?                    true
          Position?                    1
          Default value
         Accept pipeline input?       true (ByValue)
          Accept wildcard characters?  false

       

      From other help:

      "

           -- ByValue: Parameters that accept input "by value" can accept piped objects
              that have the same .NET type as their parameter value or objects that can be
              converted to that type. 
      
              For example, the Name parameter of Start-Service accepts pipeline input
              by value. It can accept string objects or objects that can be converted to
              strings.
      "

      So i thought it should discover the moref by itself , or i am thinking in wrong way?

      Can somebody check if it works on different powercli versions ?

       

      A friend of mine told me that it works for him , he runs this version:

      PowerCLI Version
      ----------------
         VMware vSphere PowerCLI 5.0 build 435427
      Is it possible that VMware vSphere PowerCLI 5.0.1 build 581491 is bugged ?