5 Replies Latest reply on Feb 7, 2013 4:06 AM by LucD

    New-VIProperty Config.Host.Value InvalidProperty

    jmedd Enthusiast
    vExpert

      vCenter 4.1 Update 2

      PowerCLI 5.1 Release 1

       

      I can successfully retrieve VMHost's IDs via:

       

      Get-VMHost | Select Name,@{N='VMHostID';E={$_.ExtensionData.Config.Host.Value}}

       

      I can also (appear) to successfully create a VIProperty for VMHostID with:

       

      New-VIProperty -Name VMHostID -ObjectType VMHost -ValueFromExtensionProperty Config.Host.Value

       

      However, when I try to use it I am greeted with an exception and no values in VMHostID

       

      Get-VMHost | Select Name,VMHostID

       

      CategoryInfo : [Get-VMHost], InvalidProperty

      FullyQualifiedErrorId: Client20_ExtensionDataHelper_GetExtensionDataByObjectContent_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVMHost

       

       

      I get the same result on multiple vCenters of the same version. Creating VIProperties from other VMHost extension properties work without issue.

       

      Is anyone able to reproduce this?

        • 1. Re: New-VIProperty Config.Host.Value InvalidProperty
          RvdNieuwendijk Virtuoso
          vExpertUser Moderators

          Hi Jonathan,

           

          I get the same error with PowerCLI 5.1 Release 1 and vCenter 5.1. It looks like a bug in the -ValueFromExtensionProperty parameter. If I do it like this:

           

          New-VIProperty -Name VMHostID -ObjectType VMHost -Value {
              param($vmhost)
              $vmhost.ExtensionData.Config.Host.Value
            }  -force
          
          

           

          it will work good.

          1 person found this helpful
          • 2. Re: New-VIProperty Config.Host.Value InvalidProperty
            jmedd Enthusiast
            vExpert

            Thanks for confirming.

             

            I already tried the below, but I included the -BasedOnExtensionProperty parameter and still got the same error. Could you confirm that also?

             

            i.e.

             

             

            New-VIProperty -Name VMHostID -ObjectType VMHost -Value {
                param($vmhost)
                $vmhost.ExtensionData.Config.Host.Value
              }  -BasedOnExtensionProperty Config.Host.Value -force

             

             

            I will need to test it tomorrow without the -BasedOnExtensionProperty parameter.

            • 3. Re: New-VIProperty Config.Host.Value InvalidProperty
              LucD Guru
              User ModeratorsvExpertCommunity Warriors

              With a slight change it works like that, just leave out the Value property in the BasedOnExtensionProperty.

               

               

              New-VIProperty -Name VMHostID -ObjectType VMHost -Value {
                  param($vmhost)
                  $vmhost.ExtensionData.Config.Host.Value
                } -BasedOnExtensionProperty Config.Host -force 


              Update: this looks a lot like a problem I once had with the Get-View cmdlet.

              When I specified the MoRef on the Property parameter, I also got an exception.

               

              Get-View -ViewType HostSystem -Property MoRef 

               

              One of the PowerCLI Dev guys explained that "MoRef, ... are client side properties and it is not possible to use them as argument for Property parameter". I wonder if this problem is not similar ?

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 4. Re: New-VIProperty Config.Host.Value InvalidProperty
                jmedd Enthusiast
                vExpert

                Thanks, that is great; works fine with the adjustment you suggested. I really wanted to use the -BasedOnExtensionProperty parameter because it makes a performance difference of about 10x.

                 

                One to add to the VIProperty module?

                • 5. Re: New-VIProperty Config.Host.Value InvalidProperty
                  LucD Guru
                  User ModeratorsCommunity WarriorsvExpert

                  Will add it.

                  There are a few more on the stack, I will need to do a new version.

                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz