VMware Cloud Community
jmedd
Enthusiast
Enthusiast
Jump to solution

New-VIProperty Config.Host.Value InvalidProperty

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?

Blog: http://jonathanmedd.net | Twitter: @jonathanmedd
Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
5 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
jmedd
Enthusiast
Enthusiast
Jump to solution

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.

Blog: http://jonathanmedd.net | Twitter: @jonathanmedd
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jmedd
Enthusiast
Enthusiast
Jump to solution

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?

Blog: http://jonathanmedd.net | Twitter: @jonathanmedd
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Will add it.

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos