VMware Cloud Community
TryllZ
Expert
Expert

The 'PhysicalNic' property of VMHostNetworkInfo type is deprecated | Get-NICTeamingPolicy..

Hi,

I'm trying to get the NICTeamingPolicy of a specific PortGroup from a particular vSwitch iSCSISwitch to change it's active NIC preference, this works using the code below, however, I also receive a message of deprecation and suggests to use VMHostNetworkAdapter which also has PortGroupName property. The below error does not appear if I only use the command $VMHosts | Get-VirtualPortGroup -Name iSCSI1.

PS C:\Users\Administrator> $VMHosts = Get-Cluster "iSCSI_Cluster" | Get-VMHost

PS C:\Users\Administrator> $VMHosts | Get-VirtualPortGroup -Name iSCSI1 | Get-NicTeamingPolicy | Set-NicTeamingPolicy -MakeNicActive vmnic3

WARNING: The 'PhysicalNic' property of VMHostNetworkInfo type is deprecated. Use 'Get-VMHostNetworkAdapter' cmdlet instead.

VirtualPortGroup     ActiveNic       StandbyNic      UnusedNic       FailbackEnabled NotifySwitches

----------------     ---------       ----------      ---------       --------------- --------------

iSCSI1               {vmnic3}                        {vmnic4}        True            True

iSCSI1               {vmnic3}                        {vmnic4}        True            True

However, when I try to use the VMHostNetworkAdapter and get its PortGroupName property as follows and use it for Get-NICTeamingPolicy I get an input object error.

PS C:\Users\Administrator> $VMHosts | Get-VirtualSwitch -Name iSCSISwitch | Get-VMHostNetworkAdapter | Select-Object -Property PortGroupName | Where {$_.PortGroupName -eq "iSCSI1"} | Get-NICTeamingPolicy

Get-NICTeamingPolicy : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.

At line:1 char:157

+ ... upName | Where {$_.PortGroupName -eq "iSCSI1"} | Get-NICTeamingPolicy

+                                                      ~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (@{PortGroupName=iSCSI1}:PSObject) [Get-NicTeamingPolicy], ParameterBindingException

    + FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetNicTeamingPolicy

Get-NICTeamingPolicy : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.

At line:1 char:157

+ ... upName | Where {$_.PortGroupName -eq "iSCSI1"} | Get-NICTeamingPolicy

+                                                      ~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (@{PortGroupName=iSCSI1}:PSObject) [Get-NicTeamingPolicy], ParameterBindingException

    + FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetNicTeamingPolicy

When I use the Get-Member it asks for a VirtualSwitch, thus I'm assuming Get-NICTeamingPolicy uses a Switch output, but again it does not ask for switch when used with Get-VirtualPortGroup.

PS C:\Users\Administrator> get-nicteamingpolicy | get-member

get-nicteamingpolicy : 10 Nov 2019 7:59:30 PM   Get-NicTeamingPolicy            Value cannot be found for the mandatory parameter VirtualSwitch

At line:1 char:1

+ get-nicteamingpolicy | get-member

+ ~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-NicTeamingPolicy], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetNicTeamingPolicy

The reason for doing this is that there is a Teaming And Failover for the Switch as well (seen below) which is not at all related to the Port Group, and I'm setting Port Group Teaming And Failover for iSCSI Network Port Binding compatibility.

vServer-2019-11-10-20-22-15.png

Is there a different command to access it, or am I missing something. This is what I'm trying to set via PowerCLI, the Teaming And Failover Order in the Port Group (seen below).

vServer-2019-11-10-20-14-20.png

vServer-2019-11-10-20-14-27.png

0 Kudos
2 Replies
LucD
Leadership
Leadership

The warning messages are just that, they can be ignored for now.
They are just meant to inform you of an upcoming change (without providing an actual date).

You shouldn't use the Select-Object cmdlet in there.
That cmdlet creates specific objects, primarily intended for output, not for passing further along the pipeline.

The warning message is in fact rather unclear.
It seems to mean that the MakeNicActive parameter of the Set-NicTeamingPolicy cmdlet is not going to accept PhysicalNic objects anymore somewhere in a future release.
But I don't really see how this warning can be avoided by using the object returned by the Get-VMHostNetworkAdapter cmdlet.
For now, I would suggest ignoring this warning.


And eventually, disable DisplayDepreciationWarnings with the Set-PowerCLIConfiguration cmdlet


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

0 Kudos
TryllZ
Expert
Expert

Hi LucD,

Thanks for the advise, appreciate that.

As for the select-object, it was just for testing, I had used the where directly as well.

Thanks once again.

0 Kudos