Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid $NetAdapterNames possible #5

Closed
JamesKehr opened this issue Oct 27, 2019 · 1 comment
Closed

Invalid $NetAdapterNames possible #5

JamesKehr opened this issue Oct 27, 2019 · 1 comment

Comments

@JamesKehr
Copy link
Contributor

Spotted a couple of problems in this section.

There is a possible condition where $AllowOutage is $false and there is only a single adapter in $configData.NetLBFOTeam.Memeber that will create an invalid NIC name.

Since $configData.NetLBFOTeam.Members resolves to a string when there is a single member, the result of the operation is char[0] of the string name. Which makes $NetAdapterNames equal to the first letter in the NIC name and will cause an error cascade whenever called.

Commented code below.

`
#region Create new SET team
# jak: alternate condition: $configData.NetLBFOTeam.Members -isnot [Array]
if ($AllowOutage -eq $true -and $configData.NetLBFOTeam.Members.Count -eq 1)
{
$NetAdapterNames = $configData.NetLBFOTeam.Members
$AdapterMigrationNeeded = $false

    # Only one pnIC - Destroy the LBFOTeam
    Remove-NetLbfoTeam -Name $configData.NetLBFOTeam.Name -Confirm:$false
}
else 
{
    <# 
        jak: It's still possible to reach this code with a single LBFO team member, if AllowOutage is $false.

        if ($configData.NetLBFOTeam.Members -is [Array])
        {
            $NetAdapterNames = $configData.NetLBFOTeam.Members[0]
        }
        else
        {
            $NetAdapterNames = $configData.NetLBFOTeam.Members
        }

    #>
    $NetAdapterNames = $configData.NetLBFOTeam.Members[0]
    $AdapterMigrationNeeded = $true

#jak: change $configData.NetLBFOTeam.Members[0] to $NetAdapterNames
    Remove-NetLbfoTeamMember -Name $NetAdapterNames -Team $configData.NetLBFOTeam.Name -Confirm:$False
}`

You also cannot remove the last member of the team. So we need to rethink what to do when -AllowOutage is false and there is only a single LBFO team member. Just in case.

Remove-NetLbfoTeamMember : Cannot remove the only member 'NIC01' of team 'Team1'
At line:30 char:9

  •     Remove-NetLbfoTeamMember -Name $NetAdapterNames -Team $config ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (MSFT_NetLbfoTea...17545E533C96}"):root/StandardCi...tLbfoTeamMember) [Remove-NetLbfoTeamMember], CimException
    • FullyQualifiedErrorId : MI RESULT 4,Remove-NetLbfoTeamMember
@dcuomo
Copy link
Member

dcuomo commented Oct 31, 2019

Oh good catch...thinking...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants