dsccommunity / NetworkingDsc

DSC resources for configuring settings related to networking.
https://dsccommunity.org
MIT License
227 stars 89 forks source link

Include hidden adapters by default? #499

Open gaelicWizard opened 3 years ago

gaelicWizard commented 3 years ago

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

We have a need to configure a setting on a hidden network adapter, easily enough handled by adding -IncludeHidden to *-NetAdapter et al.

Verbose logs showing the problem

Suggested solution to the issue

Options: 1: add IncludeHidden parameter to most of the resources in NetworkingDsc, which in turn passes -IncludeHidden to the appropriate cmdlets. I started #495 on this already, but then @PlagueHO suggested a much simpler solution:

  1. Add -IncludeHidden to all the cmdlets, anyways.

My vote is for option 2 with one exception: add IncludeHidden parameter to NetAdapterName resource. All other resources key off of Name/InterfaceAlias so including hidden adapters when searching seems like it wouldn't break anything: the unique name is already specified. But, for NetAdapterName the key is Description so adding -IncludeHidden could potentially increase the search space unexpectedly if wildcards are used.

The DSC configuration that is used to reproduce the issue (as detailed as possible)

# insert configuration here

The operating system the target node is running

OsName : Microsoft Windows 10 Pro for Workstations OsOperatingSystemSKU : 161 OsArchitecture : 64-bit WindowsVersion : 2009 WindowsBuildLabEx : 19041.1.amd64fre.vb_release.191206-1406 OsLanguage : en-US OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

Name Value


PSVersion 5.1.19041.906 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.906 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)

8.2.0 NetworkingDsc

PlagueHO commented 3 years ago

I tend to lean towards Option 2 as well - but good point regarding NetAdapterName resource. It would be good to confirm what options we have there.

PlagueHO commented 3 years ago

Also keen to get community input on this one as there might be some reasons that we need to make this optional that I'm not aware of.

gaelicWizard commented 3 years ago

Adapter names must already be unique, so whenever the adapter name is specified explicitly the -IncludeHidden switch should never change which adapter is actually targeted. For NetAdapterName, it supports wildcards:

 get-netadapter -InterfaceDescription "*"

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
EPN Miniport              LogMeIn Hamachi Virtual Ethernet Ada...       3 Up           7A-79-19-05-B3-38        10 Gbps
Ethernet                  Microsoft Hyper-V Network Adapter             4 Up           00-15-5D-CC-F0-02         1 Gbps 

versus

 get-netadapter -InterfaceDescription "*" -IncludeHidden

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
Teredo Tunneling Pseud...                                               7 Disabled     00-00-00-00-00...       100 Kbps
EPN Miniport              LogMeIn Hamachi Virtual Ethernet Ada...       3 Up           7A-79-19-05-B3-38        10 Gbps
Microsoft IP-HTTPS Pla...                                               6 Not Present                             0 bps
Ethernet (Kernel Debug... Microsoft Kernel Debug Network Adapter        5 Not Present                             0 bps
Ethernet                  Microsoft Hyper-V Network Adapter             4 Up           00-15-5D-CC-F0-02         1 Gbps
6to4 Adapter                                                            2 Not Present                             0 bps