dsccommunity / dsccommunity/NetworkingDsc

NetAdapterName: InterfaceNumber doesn't seem to be working as it should

Open
#382 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
PowerShell
Stars
235
Forks
93
PR merge metrics
No merged PRs in 30d

Description

System.InvalidOperationException: A network adapter matching the parameters was not found. Please correct the properties and try again.

Details of the scenario you tried and the problem that is occurring

Doesn't seem to find the adapter based off the filter. Looking at the Find-Adapter function, I show:

VERBOSE: Find-NetworkAdapter: Finding network adapters matching the parameters.
VERBOSE: Find-NetworkAdapter: Found all network adapters because no filter parameters provided.
VERBOSE: Find-NetworkAdapter: 2 network adapters were found matching the parameters.
System.InvalidOperationException: Please adjust the parameters or specify IgnoreMultipleMatchingAdapters to only use the first and try again.

Looking at the code https://github.com/PowerShell/NetworkingDsc/blob/3db6d5ea444ee60ca4ffd8fd4e134763cd070e08/Modules/NetworkingDsc.Common/NetworkingDsc.Common.psm1#L235

And it appears you need the parameter IgnoreMultipleMatchingAdapters to be true and you need to specify the adapter number.

Find-NetworkAdapter -InterfaceNumber 1 -IgnoreMultipleMatchingAdapters $true -verbose

Suggested solution to the issue

Not sure what this variable would be used for to be honest, so can't provide a solution. I'm assuming it's for other filters that return more than 1 adapter and it shouldn't. In this case, I feel like if specify an interface number, it should just return that number from the array and not get the multiple matching error.

The DSC configuration that is used to reproduce the issue (as detailed as possible)
NetAdapterName RenameNetAdapterPrivate {
            NewName           = 'Private'
            DriverDescription = 'Hyper-V Virtual Ethernet Adapter'
            InterfaceNumber   = 1
        }
The operating system the target node is running

OsName : Microsoft Windows Server 2016 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture : 64-bit
WindowsBuildLabEx : 14393.2828.amd64fre.rs1_release_inmarket.190216-1457
OsLanguage : en-US
OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

Name Value


PSVersion 5.1.14393.2828
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.2828
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Version of the DSC module that was used ('dev' if using current dev branch)

NetAdapterName NetworkingDsc 7.0.0.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Modules/NetworkingDsc.Common/NetworkingDsc.Common.psm1 around line 235 and reproduce the NetAdapterName configuration using InterfaceNumber 1 on the reported Windows Server environment. Check whether the adapter lookup treats InterfaceNumber as a unique filter, then verify the expected behavior against the multiple-match error and verbose output.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.