VMware Cloud Community
halr9000
Commander
Commander

related bugs in set-vmhostnetwork and set-vmhostnetworkadapter

The Set-VMHostNetwork cmdlet has a param called DnsDhcpDevice and accordin to the help file, it should accept "a ServiceConsoleNIC object, a VMKernelNIC object in case of ESX Visor, or the NIC name as a string".

The Set-VMHostNetworkAdapter cmdlet has a param called PhysicalNic which the help says should take a "PhysicalNic[]".

In the case of both of these parameters above, no cmdlet exists which can produce an object of the required types. The Get-VMHostNetwork cmdlet has PhysicalNic and VirtualNic properties which ideally, should do the trick but the type validation does not match and you get an error if you try it.

To be consistent, there really should be a Get-VMHostNetworkAdapter cmdlet which can return the correct objects, and the code should be changed on one side (the VMHostNetworkInfoImpl object) or the other (the set-cmdlets) to match whatever object type you guys choose.

In addition, I could not get a string to work for DnsDhcpDevice.

And also, for the Set-VMHostNetworkAdapter cmdlet VirtualNic parameter, I was actually able to make this one work by using (get-vmhostnetwork).virtualnic, but that obviously is not ideal.

I think all of these parameters should accept device names as well, e.g. vmnic0.

And last but not least, is there a workaround for the pnic stuff? I may eventually be able to get this to work but I don't have the time to mess with it at the moment.

PS > $pnic = New-Object vmware.VimAutomation.Types.Host.NIC.PhysicalNic
New-Object : Constructor not found. Cannot find an appropriate constructor for type v
mware.VimAutomation.Types.Host.NIC.PhysicalNic.
At line:1 char:19
+ $pnic = New-Object  <<<< vmware.VimAutomation.Types.Host.NIC.PhysicalNic






Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
Reply
0 Kudos
4 Replies
nnedev
VMware Employee
VMware Employee

Thanks Hal. The issues will be logged in our bug tracking system.

Regards, Nedko Nedev PowerCLI Development Team
yboychev
Hot Shot
Hot Shot

Hi Hal,

To start with, yes the usage of the Set-VmHostNetwork (Set-VmHostNetworkAdapter) cmdlets is not the most intuitive thing on the earth but it does provide the capability to do the work you need. I'll give a short example how to set the the DnsFromDhcp and DnsDhcpDevice using the Get/Set-VmHodstNetwork cmdlets.

Connect-VIServer 10.23.xxx.xxx ...
$vmHostNetworkInfo = Get-VmHostNetwork -VmHost (Get-VmHost -Name MyName) 
Set-VmHostNetwork  -Network $vmHostNetworkInfo -DnsFromDhcp $true -DnsDhcpDevice $vmHostNetworkInfo.ConsoleNic[0] --> This is not a valid DnsDhcpDevice as it has dhcp networking settings
DSet-VMHostNetwork : 9/4/2008 4:38:29 PM    Set-VMHostNetwork    448C9270-FF37-42FB-807F-86F37E931EFC    A specified parameter was not correct.    
$vmHostNetworkInfo = Set-VmHostNetwork  -Network $vmHostNetworkInfo -DnsFromDhcp $true -DnsDhcpDevice $vmHostNetworkInfo.ConsoleNic[1] --> This one has static ip
$vmHostNetworkInfo.DnsDhcpDevice
vswif1 
$vmHostNetworkInfo = Set-VmHostNetwork  -Network $vmHostNetworkInfo -DnsFromDhcp $true -DnsDhcpDevice vswif2 -->also static ip
$vmHostNetworkInfo
vswif2 

Hopefully this helps

/Yavor

Reply
0 Kudos
halr9000
Commander
Commander

Thanks for the help guys. Yavor, if possible could you repost your example using the forum markup I just sent you via PM?

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
Reply
0 Kudos
yboychev
Hot Shot
Hot Shot

Hi Hal and all,

Just want to mention that the described problem is now resolved with the newly released PowerCLI4.0 Update 1.

Get-VmHostNetworkAdapter cmdlet is now implemented and it has -Console, -Physical and VmKernel switches that will do the work. Enjoy it!

\Yavor

Reply
0 Kudos