Skip to content

Commit b44569c

Browse files
committed
Expose -IncludeHidden parameter
NetAdapter module Cmdlets have an -IncludeHidden flag which allows access to adapters which are hidden; expose that flag here. - Add flag to MOF schemas - Add function parameter and comment based help - NetAdapterName should now be working - NetAdapterRdma should now be working - NetAdapterRss should now be working - NetAdapterState should now be working
1 parent 983c54b commit b44569c

26 files changed

Lines changed: 428 additions & 36 deletions

source/DSCResources/DSC_DefaultGatewayAddress/DSC_DefaultGatewayAddress.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ function Assert-ResourceProperty
292292
$Address
293293
)
294294

295-
if (-not (Get-NetAdapter | Where-Object -Property Name -EQ $InterfaceAlias ))
295+
if (-not (Get-NetAdapter -IncludeHidden:$IncludeHidden | Where-Object -Property Name -EQ $InterfaceAlias ))
296296
{
297297
New-InvalidOperationException `
298298
-Message ($script:localizedData.InterfaceNotAvailableError -f $InterfaceAlias)

source/DSCResources/DSC_NetAdapterAdvancedProperty/DSC_NetAdapterAdvancedProperty.psm1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
1717
.PARAMETER NetworkAdapterName
1818
Specifies the name of the network adapter to set the advanced property for.
1919
20+
.PARAMETER IncludeHidden
21+
This switch will causes hidden network adapters to be included in the search.
22+
2023
.PARAMETER RegistryKeyword
2124
Specifies the registry keyword that should be in desired state.
2225
@@ -33,6 +36,10 @@ function Get-TargetResource
3336
[System.String]
3437
$NetworkAdapterName,
3538

39+
[Parameter()]
40+
[System.Boolean]
41+
$IncludeHidden = $false,
42+
3643
[Parameter(Mandatory = $true)]
3744
[System.String]
3845
$RegistryKeyword,
@@ -51,6 +58,7 @@ function Get-TargetResource
5158
{
5259
$netAdapterAdvancedProperty = Get-NetAdapterAdvancedProperty `
5360
-Name $networkAdapterName `
61+
-IncludeHidden:$IncludeHidden `
5462
-RegistryKeyword $RegistryKeyword `
5563
-ErrorAction Stop
5664
}
@@ -85,6 +93,9 @@ function Get-TargetResource
8593
.PARAMETER NetworkAdapterName
8694
Specifies the name of the network adapter to set the advanced property for.
8795
96+
.PARAMETER IncludeHidden
97+
This switch will causes hidden network adapters to be included in the search.
98+
8899
.PARAMETER RegistryKeyword
89100
Specifies the registry keyword that should be in desired state.
90101
@@ -100,6 +111,10 @@ function Set-TargetResource
100111
[System.String]
101112
$NetworkAdapterName,
102113

114+
[Parameter()]
115+
[System.Boolean]
116+
$IncludeHidden = $false,
117+
103118
[Parameter(Mandatory = $true)]
104119
[System.String]
105120
$RegistryKeyword,
@@ -118,6 +133,7 @@ function Set-TargetResource
118133
{
119134
$netAdapterAdvancedProperty = Get-NetAdapterAdvancedProperty `
120135
-Name $networkAdapterName `
136+
-IncludeHidden:$IncludeHidden `
121137
-RegistryKeyword $RegistryKeyword `
122138
-ErrorAction Stop
123139
}
@@ -146,6 +162,7 @@ function Set-TargetResource
146162
Set-NetAdapterAdvancedProperty `
147163
-RegistryValue $RegistryValue `
148164
-Name $networkAdapterName `
165+
-IncludeHidden:$IncludeHidden `
149166
-RegistryKeyword $RegistryKeyword
150167
}
151168
}
@@ -158,6 +175,9 @@ function Set-TargetResource
158175
.PARAMETER NetworkAdapterName
159176
Specifies the name of the network adapter to set the advanced property for.
160177
178+
.PARAMETER IncludeHidden
179+
This switch will causes hidden network adapters to be included in the search.
180+
161181
.PARAMETER RegistryKeyword
162182
Specifies the registry keyword that should be in desired state.
163183
@@ -174,6 +194,10 @@ function Test-TargetResource
174194
[System.String]
175195
$NetworkAdapterName,
176196

197+
[Parameter()]
198+
[System.Boolean]
199+
$IncludeHidden = $false,
200+
177201
[Parameter(Mandatory = $true)]
178202
[System.String]
179203
$RegistryKeyword,
@@ -192,6 +216,7 @@ function Test-TargetResource
192216
{
193217
$netAdapterAdvancedProperty = Get-NetAdapterAdvancedProperty `
194218
-Name $networkAdapterName `
219+
-IncludeHidden:$IncludeHidden `
195220
-RegistryKeyword $RegistryKeyword `
196221
-ErrorAction Stop
197222
}

source/DSCResources/DSC_NetAdapterAdvancedProperty/DSC_NetAdapterAdvancedProperty.schema.mof

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
class DSC_NetAdapterAdvancedProperty : OMI_BaseResource
33
{
44
[Key, Description("Specifies the name of the network adapter to set the advanced property for.")] String NetworkAdapterName;
5+
[Write, Description("This switch will causes hidden network adapters to be included in the search.")] Boolean IncludeHidden;
56
[Key, Description("Specifies the registry keyword that should be in desired state.")] String RegistryKeyword;
67
[Required, Description("Specifies the value of the registry keyword.")] String RegistryValue;
78
[Read, Description("Output Display value of selected RegistryKeyword.")] String DisplayValue;

source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
1717
.PARAMETER InterfaceAlias
1818
Specifies the alias of a network interface. Supports the use of '*'.
1919
20+
.PARAMETER IncludeHidden
21+
This switch will causes hidden network adapters to be included in the search.
22+
2023
.PARAMETER ComponentId
2124
Specifies the underlying name of the transport or filter in the following
2225
form - ms_xxxx, such as ms_tcpip.
@@ -35,6 +38,10 @@ function Get-TargetResource
3538
[System.String]
3639
$InterfaceAlias,
3740

41+
[Parameter()]
42+
[System.Boolean]
43+
$IncludeHidden = $false,
44+
3845
[Parameter(Mandatory = $true)]
3946
[ValidateNotNullOrEmpty()]
4047
[System.String]
@@ -86,6 +93,9 @@ function Get-TargetResource
8693
.PARAMETER InterfaceAlias
8794
Specifies the alias of a network interface. Supports the use of '*'.
8895
96+
.PARAMETER IncludeHidden
97+
This switch will causes hidden network adapters to be included in the search.
98+
8999
.PARAMETER ComponentId
90100
Specifies the underlying name of the transport or filter in the following
91101
form - ms_xxxx, such as ms_tcpip.
@@ -103,6 +113,10 @@ function Set-TargetResource
103113
[System.String]
104114
$InterfaceAlias,
105115

116+
[Parameter()]
117+
[System.Boolean]
118+
$IncludeHidden = $false,
119+
106120
[Parameter(Mandatory = $true)]
107121
[ValidateNotNullOrEmpty()]
108122
[System.String]
@@ -151,6 +165,9 @@ function Set-TargetResource
151165
.PARAMETER InterfaceAlias
152166
Specifies the alias of a network interface. Supports the use of '*'.
153167
168+
.PARAMETER IncludeHidden
169+
This switch will causes hidden network adapters to be included in the search.
170+
154171
.PARAMETER ComponentId
155172
Specifies the underlying name of the transport or filter in the following
156173
form - ms_xxxx, such as ms_tcpip.
@@ -169,6 +186,10 @@ function Test-TargetResource
169186
[System.String]
170187
$InterfaceAlias,
171188

189+
[Parameter()]
190+
[System.Boolean]
191+
$IncludeHidden = $false,
192+
172193
[Parameter(Mandatory = $true)]
173194
[ValidateNotNullOrEmpty()]
174195
[System.String]
@@ -231,6 +252,9 @@ function Test-TargetResource
231252
.PARAMETER InterfaceAlias
232253
Specifies the alias of a network interface. Supports the use of '*'.
233254
255+
.PARAMETER IncludeHidden
256+
This switch will causes hidden network adapters to be included in the search.
257+
234258
.PARAMETER ComponentId
235259
Specifies the underlying name of the transport or filter in the following
236260
form - ms_xxxx, such as ms_tcpip.
@@ -249,6 +273,10 @@ function Get-Binding
249273
[System.String]
250274
$InterfaceAlias,
251275

276+
[Parameter()]
277+
[System.Boolean]
278+
$IncludeHidden = $false,
279+
252280
[Parameter(Mandatory = $true)]
253281
[ValidateNotNullOrEmpty()]
254282
[System.String]
@@ -260,7 +288,7 @@ function Get-Binding
260288
$State = 'Enabled'
261289
)
262290

263-
if (-not (Get-NetAdapter -Name $InterfaceAlias -ErrorAction SilentlyContinue))
291+
if (-not (Get-NetAdapter -Name $InterfaceAlias -IncludeHidden:$IncludeHidden -ErrorAction SilentlyContinue))
264292
{
265293
New-InvalidArgumentException `
266294
-Message ($script:localizedData.InterfaceNotAvailableError -f $InterfaceAlias) `

source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.schema.mof

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
class DSC_NetAdapterBinding : OMI_BaseResource
33
{
44
[Key, Description("Specifies the alias of a network interface. Supports the use of '*'.")] string InterfaceAlias;
5+
[Write, Description("This switch will causes hidden network adapters to be included in the search.")] Boolean IncludeHidden;
56
[Key, Description("Specifies the underlying name of the transport or filter in the following form - ms_xxxx, such as ms_tcpip.")] string ComponentId;
67
[Write, Description("Specifies if the component ID for the Interface should be Enabled or Disabled."), ValueMap{"Enabled", "Disabled"}, Values{"Enabled", "Disabled"}] string State;
78
[Read, Description("Returns the current state of the component ID for the Interfaces."), ValueMap{"Enabled", "Disabled","Mixed"}, Values{"Enabled", "Disabled","Mixed"}] string CurrentState;

source/DSCResources/DSC_NetAdapterLso/DSC_NetAdapterLso.psm1

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
1717
.PARAMETER Name
1818
Specifies the name of the network adapter to check.
1919
20+
.PARAMETER IncludeHidden
21+
This switch will causes hidden network adapters to be included in the search.
22+
2023
.PARAMETER Protocol
2124
Specifies which protocol to target.
2225
@@ -33,6 +36,10 @@ function Get-TargetResource
3336
[System.String]
3437
$Name,
3538

39+
[Parameter()]
40+
[System.Boolean]
41+
$IncludeHidden = $false,
42+
3643
[Parameter(Mandatory = $true)]
3744
[ValidateSet('V1IPv4', 'IPv4', 'IPv6')]
3845
[System.String]
@@ -50,7 +57,9 @@ function Get-TargetResource
5057

5158
try
5259
{
53-
$netAdapter = Get-NetAdapterLso -Name $Name -ErrorAction Stop
60+
$netAdapter = Get-NetAdapterLso -Name $Name `
61+
-IncludeHidden:$IncludeHidden `
62+
-ErrorAction Stop
5463
}
5564
catch
5665
{
@@ -99,6 +108,9 @@ function Get-TargetResource
99108
.PARAMETER Name
100109
Specifies the name of the network adapter to check.
101110
111+
.PARAMETER IncludeHidden
112+
This switch will causes hidden network adapters to be included in the search.
113+
102114
.PARAMETER Protocol
103115
Specifies which protocol to target.
104116
@@ -114,6 +126,10 @@ function Set-TargetResource
114126
[System.String]
115127
$Name,
116128

129+
[Parameter()]
130+
[System.Boolean]
131+
$IncludeHidden = $false,
132+
117133
[Parameter(Mandatory = $true)]
118134
[ValidateSet('V1IPv4', 'IPv4', 'IPv6')]
119135
[System.String]
@@ -131,7 +147,9 @@ function Set-TargetResource
131147

132148
try
133149
{
134-
$netAdapter = Get-NetAdapterLso -Name $Name -ErrorAction Stop
150+
$netAdapter = Get-NetAdapterLso -Name $Name `
151+
-IncludeHidden:$IncludeHidden `
152+
-ErrorAction Stop
135153
}
136154
catch
137155
{
@@ -154,7 +172,9 @@ function Set-TargetResource
154172
$Name, $Protocol, $($netAdapter.V1IPv4Enabled.ToString()), $($State.ToString()) )
155173
) -join '')
156174

157-
Set-NetAdapterLso -Name $Name -V1IPv4Enabled $State
175+
Set-NetAdapterLso -Name $Name `
176+
-IncludeHidden:$IncludeHidden `
177+
-ErrorAction Stop
158178
}
159179
elseif ($Protocol -eq 'IPv4' -and $State -ne $netAdapter.IPv4Enabled)
160180
{
@@ -164,7 +184,9 @@ function Set-TargetResource
164184
$Name, $Protocol, $($netAdapter.IPv4Enabled.ToString()), $($State.ToString()) )
165185
) -join '')
166186

167-
Set-NetAdapterLso -Name $Name -IPv4Enabled $State
187+
Set-NetAdapterLso -Name $Name `
188+
-IncludeHidden:$IncludeHidden `
189+
-ErrorAction Stop
168190
}
169191
elseif ($Protocol -eq 'IPv6' -and $State -ne $netAdapter.IPv6Enabled)
170192
{
@@ -174,7 +196,9 @@ function Set-TargetResource
174196
$Name, $Protocol, $($netAdapter.IPv6Enabled.ToString()), $($State.ToString()) )
175197
) -join '')
176198

177-
Set-NetAdapterLso -Name $Name -IPv6Enabled $State
199+
Set-NetAdapterLso -Name $Name `
200+
-IncludeHidden:$IncludeHidden `
201+
-ErrorAction Stop
178202
}
179203
}
180204
}
@@ -186,6 +210,9 @@ function Set-TargetResource
186210
.PARAMETER Name
187211
Specifies the name of the network adapter to check.
188212
213+
.PARAMETER IncludeHidden
214+
This switch will causes hidden network adapters to be included in the search.
215+
189216
.PARAMETER Protocol
190217
Specifies which protocol to target.
191218
@@ -202,6 +229,10 @@ function Test-TargetResource
202229
[System.String]
203230
$Name,
204231

232+
[Parameter()]
233+
[System.Boolean]
234+
$IncludeHidden = $false,
235+
205236
[Parameter(Mandatory = $true)]
206237
[ValidateSet('V1IPv4', 'IPv4', 'IPv6')]
207238
[System.String]
@@ -219,7 +250,9 @@ function Test-TargetResource
219250

220251
try
221252
{
222-
$netAdapter = Get-NetAdapterLso -Name $Name -ErrorAction Stop
253+
$netAdapter = Get-NetAdapterLso -Name $Name `
254+
-IncludeHidden:$IncludeHidden `
255+
-ErrorAction Stop
223256
}
224257
catch
225258
{

source/DSCResources/DSC_NetAdapterLso/DSC_NetAdapterLso.schema.mof

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
class DSC_NetAdapterLso : OMI_BaseResource
33
{
44
[Key, Description("Specifies the name of network adapter.")] String Name;
5+
[Write, Description("This switch will causes hidden network adapters to be included in the search.")] Boolean IncludeHidden;
56
[Key, Description("Specifies which protocol to make changes to."), ValueMap{"V1IPv4","IPv4","IPv6"}, Values{"V1IPv4","IPv4","IPv6"}] String Protocol;
67
[Required, Description("Specifies whether LSO should be enabled or disabled.")] Boolean State;
78
};

0 commit comments

Comments
 (0)