VMware Cloud Community
tdubb123
Expert
Expert
Jump to solution

ying to new-viproperty vCenterserver

trying to get vmhost info and management IP plus vcenter but this is not working

 

New-VIProperty -Name vCenterServer -ObjectType VMHost -Value {$Args[0].Uid.Split(“:”)[0].Split(“@”)[1]} -Force | Out-Null

get-vmhost | get-vmhostnetworkadapter | ?{$_.name -eq "vmk0" } | select VMhost, name, IP, vCenterServer

 

vCenterServer is blank

 

any idea?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The ObjectType parameter should be HostVirtualNic

New-VIProperty -Name vCenterServer -ObjectType HostVirtualNic -Value {
    $Args[0].Uid.Split(“:”)[0].Split(“@”)[1]
} -Force | Out-Null

Get-VMHost | Get-VMHostNetworkAdapter | 
Where-Object{$_.name -eq "vmk0" } | 
select VMhost, name, IP, vCenterServer

 


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

View solution in original post

5 Replies
LucD
Leadership
Leadership
Jump to solution

The ObjectType parameter should be HostVirtualNic

New-VIProperty -Name vCenterServer -ObjectType HostVirtualNic -Value {
    $Args[0].Uid.Split(“:”)[0].Split(“@”)[1]
} -Force | Out-Null

Get-VMHost | Get-VMHostNetworkAdapter | 
Where-Object{$_.name -eq "vmk0" } | 
select VMhost, name, IP, vCenterServer

 


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

tdubb123
Expert
Expert
Jump to solution

Thanks Luc,

 

how come this does not work?

 

New-VIProperty -Name vCenterServer -ObjectType VMHost -Value {$Args[0].Uid.Split(“:”)[0].Split(“@”)[1]} -Force | Out-Null

 

get-vmhost | select name, @{n="ip";e={$_.extensiondata.summary.managementserverIp}}, vCenterServer

0 Kudos
bryanvaneeden
Hot Shot
Hot Shot
Jump to solution

@tdubb123, Lucd was right, you were asking the VMhost network adapter information, and not the VMhost information. That is why the vCenterServer Property stayed empty.

As to your second question, that works fine on my end. The code seems alright to me.

Visit my blog at https://vcloudvision.com!
tdubb123
Expert
Expert
Jump to solution

I dont know why under the IP and vCenterServer colums is showing the same IP

0 Kudos
tdubb123
Expert
Expert
Jump to solution

NM, I got confused with managementServerIP as the vmkernel IP (vmk0)

 

Thanks again

0 Kudos