From f8c2dcd3e48497d6c93243810caa96a86cd1b332 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Wed, 19 May 2021 17:58:39 -0400 Subject: [PATCH 01/20] Clean spurious newline at file beginning --- source/DSCResources/DSC_NetBios/DSC_NetBios.schema.mof | 1 - .../DSC_NetworkTeamInterface/DSC_NetworkTeamInterface.schema.mof | 1 - .../DSC_WaitForNetworkTeam/DSC_WaitForNetworkTeam.schema.mof | 1 - 3 files changed, 3 deletions(-) diff --git a/source/DSCResources/DSC_NetBios/DSC_NetBios.schema.mof b/source/DSCResources/DSC_NetBios/DSC_NetBios.schema.mof index c4560067..9574a7ff 100644 --- a/source/DSCResources/DSC_NetBios/DSC_NetBios.schema.mof +++ b/source/DSCResources/DSC_NetBios/DSC_NetBios.schema.mof @@ -1,4 +1,3 @@ - [ClassVersion("1.0.0.0"), FriendlyName("NetBios")] class DSC_NetBios : OMI_BaseResource { diff --git a/source/DSCResources/DSC_NetworkTeamInterface/DSC_NetworkTeamInterface.schema.mof b/source/DSCResources/DSC_NetworkTeamInterface/DSC_NetworkTeamInterface.schema.mof index b7b36416..a4dc056d 100644 --- a/source/DSCResources/DSC_NetworkTeamInterface/DSC_NetworkTeamInterface.schema.mof +++ b/source/DSCResources/DSC_NetworkTeamInterface/DSC_NetworkTeamInterface.schema.mof @@ -1,4 +1,3 @@ - [ClassVersion("1.0"), FriendlyName("NetworkTeamInterface")] class DSC_NetworkTeamInterface : OMI_BaseResource { diff --git a/source/DSCResources/DSC_WaitForNetworkTeam/DSC_WaitForNetworkTeam.schema.mof b/source/DSCResources/DSC_WaitForNetworkTeam/DSC_WaitForNetworkTeam.schema.mof index 3034cf9a..bded4b01 100644 --- a/source/DSCResources/DSC_WaitForNetworkTeam/DSC_WaitForNetworkTeam.schema.mof +++ b/source/DSCResources/DSC_WaitForNetworkTeam/DSC_WaitForNetworkTeam.schema.mof @@ -1,4 +1,3 @@ - [ClassVersion("1.0.0.0"), FriendlyName("WaitForNetworkTeam")] class DSC_WaitForNetworkTeam : OMI_BaseResource { From e98d1aa7994204962ef0fe97aade744dcf498f25 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Wed, 19 May 2021 21:37:44 -0400 Subject: [PATCH 02/20] Reformat whitespace for diffability to match other modues --- .../DSC_DnsConnectionSuffix.psm1 | 4 ++- .../DSC_FirewallProfile.psm1 | 9 ++++-- .../DSC_IPAddress/DSC_IPAddress.psm1 | 14 ++++++--- .../DSC_IPAddressOption.psm1 | 4 ++- .../DSC_NetAdapterLso/DSC_NetAdapterLso.psm1 | 24 ++++++++++---- .../DSC_NetAdapterName.psm1 | 3 +- .../DSC_NetAdapterRdma.psm1 | 16 +++++++--- .../DSC_NetAdapterRsc/DSC_NetAdapterRsc.psm1 | 20 +++++++++--- .../DSC_NetAdapterRss/DSC_NetAdapterRss.psm1 | 16 +++++++--- .../DSC_NetAdapterState.psm1 | 17 +++++++--- .../DSCResources/DSC_NetBios/DSC_NetBios.psm1 | 31 ++++++++++++------- .../DSC_NetConnectionProfile.psm1 | 6 ++-- .../DSC_NetIPInterface.psm1 | 3 +- .../DSC_NetworkTeam/DSC_NetworkTeam.psm1 | 27 +++++++++++----- .../DSC_ProxySettings/DSC_ProxySettings.psm1 | 25 ++++++++++----- .../DSC_WinsServerAddress.psm1 | 5 ++- .../NetworkingDsc.Common.psm1 | 8 +++-- 17 files changed, 168 insertions(+), 64 deletions(-) diff --git a/source/DSCResources/DSC_DnsConnectionSuffix/DSC_DnsConnectionSuffix.psm1 b/source/DSCResources/DSC_DnsConnectionSuffix/DSC_DnsConnectionSuffix.psm1 index cb6aad4f..f89526b2 100644 --- a/source/DSCResources/DSC_DnsConnectionSuffix/DSC_DnsConnectionSuffix.psm1 +++ b/source/DSCResources/DSC_DnsConnectionSuffix/DSC_DnsConnectionSuffix.psm1 @@ -60,7 +60,9 @@ function Get-TargetResource $Ensure = 'Present' ) - $dnsClient = Get-DnsClient -InterfaceAlias $InterfaceAlias -ErrorAction SilentlyContinue + $dnsClient = Get-DnsClient ` + -InterfaceAlias $InterfaceAlias ` + -ErrorAction SilentlyContinue $targetResource = @{ InterfaceAlias = $dnsClient.InterfaceAlias diff --git a/source/DSCResources/DSC_FirewallProfile/DSC_FirewallProfile.psm1 b/source/DSCResources/DSC_FirewallProfile/DSC_FirewallProfile.psm1 index 9e0a3c79..1a05d3a9 100644 --- a/source/DSCResources/DSC_FirewallProfile/DSC_FirewallProfile.psm1 +++ b/source/DSCResources/DSC_FirewallProfile/DSC_FirewallProfile.psm1 @@ -46,7 +46,8 @@ function Get-TargetResource ) -join '' ) # Get the current Dns Client Global Settings - $netFirewallProfile = Get-NetFirewallProfile -Name $Name ` + $netFirewallProfile = Get-NetFirewallProfile ` + -Name $Name ` -ErrorAction Stop # Generate the return object. @@ -231,7 +232,8 @@ function Set-TargetResource ) -join '' ) # Get the current Firewall Profile Settings - $netFirewallProfile = Get-NetFirewallProfile -Name $Name ` + $netFirewallProfile = Get-NetFirewallProfile ` + -Name $Name ` -ErrorAction Stop # Generate a list of parameters that will need to be changed. @@ -442,7 +444,8 @@ function Test-TargetResource $desiredConfigurationMatch = $true # Get the current Dns Client Global Settings - $netFirewallProfile = Get-NetFirewallProfile -Name $Name ` + $netFirewallProfile = Get-NetFirewallProfile ` + -Name $Name ` -ErrorAction Stop # Check each parameter diff --git a/source/DSCResources/DSC_IPAddress/DSC_IPAddress.psm1 b/source/DSCResources/DSC_IPAddress/DSC_IPAddress.psm1 index a715f64c..18bd8dc1 100644 --- a/source/DSCResources/DSC_IPAddress/DSC_IPAddress.psm1 +++ b/source/DSCResources/DSC_IPAddress/DSC_IPAddress.psm1 @@ -228,7 +228,8 @@ function Set-TargetResource try { # Apply the specified IP configuration - New-NetIPAddress @newNetIPAddressParameters -ErrorAction Stop + New-NetIPAddress @newNetIPAddressParameters ` + -ErrorAction Stop } catch [Microsoft.Management.Infrastructure.CimException] { @@ -240,7 +241,8 @@ function Set-TargetResource Setting New-NetIPaddress will throw [Microsoft.Management.Infrastructure.CimException] if the IP address is already set. Need to check to make sure the IP is set on correct interface #> - $verifyNetIPAddressAdapter = Get-NetIPAddress @verifyNetIPAddressAdapterParam -ErrorAction SilentlyContinue + $verifyNetIPAddressAdapter = Get-NetIPAddress @verifyNetIPAddressAdapterParam ` + -ErrorAction SilentlyContinue if ($verifyNetIPAddressAdapter.InterfaceAlias -eq $InterfaceAlias) { @@ -343,7 +345,9 @@ function Test-TargetResource } } # while - $ipAddressObject = Get-IPAddressPrefix -IPAddress $IPAddress -AddressFamily $AddressFamily + $ipAddressObject = Get-IPAddressPrefix ` + -IPAddress $IPAddress ` + -AddressFamily $AddressFamily # Test if the IP Address passed is present foreach ($singleIP in $ipAddressObject) @@ -480,7 +484,9 @@ function Assert-ResourceProperty { $singleIP = ($singleIPAddress -split '/')[0] - Assert-IPAddress -Address $singleIP -AddressFamily $AddressFamily + Assert-IPAddress ` + -Address $singleIP ` + -AddressFamily $AddressFamily } foreach ($prefixLength in $prefixLengthArray) diff --git a/source/DSCResources/DSC_IPAddressOption/DSC_IPAddressOption.psm1 b/source/DSCResources/DSC_IPAddressOption/DSC_IPAddressOption.psm1 index 8c90074e..06203372 100644 --- a/source/DSCResources/DSC_IPAddressOption/DSC_IPAddressOption.psm1 +++ b/source/DSCResources/DSC_IPAddressOption/DSC_IPAddressOption.psm1 @@ -83,7 +83,9 @@ function Set-TargetResource if ($currentConfig.SkipAsSource -ne $SkipAsSource) { - Set-NetIPAddress -IPAddress $IPAddress -SkipAsSource $SkipAsSource + Set-NetIPAddress ` + -IPAddress $IPAddress ` + -SkipAsSource $SkipAsSource } } diff --git a/source/DSCResources/DSC_NetAdapterLso/DSC_NetAdapterLso.psm1 b/source/DSCResources/DSC_NetAdapterLso/DSC_NetAdapterLso.psm1 index 839e2d38..c8feece8 100644 --- a/source/DSCResources/DSC_NetAdapterLso/DSC_NetAdapterLso.psm1 +++ b/source/DSCResources/DSC_NetAdapterLso/DSC_NetAdapterLso.psm1 @@ -50,7 +50,9 @@ function Get-TargetResource try { - $netAdapter = Get-NetAdapterLso -Name $Name -ErrorAction Stop + $netAdapter = Get-NetAdapterLso ` + -Name $Name ` + -ErrorAction Stop } catch { @@ -131,7 +133,9 @@ function Set-TargetResource try { - $netAdapter = Get-NetAdapterLso -Name $Name -ErrorAction Stop + $netAdapter = Get-NetAdapterLso ` + -Name $Name ` + -ErrorAction Stop } catch { @@ -154,7 +158,9 @@ function Set-TargetResource $Name, $Protocol, $($netAdapter.V1IPv4Enabled.ToString()), $($State.ToString()) ) ) -join '') - Set-NetAdapterLso -Name $Name -V1IPv4Enabled $State + Set-NetAdapterLso ` + -Name $Name ` + -V1IPv4Enabled $State } elseif ($Protocol -eq 'IPv4' -and $State -ne $netAdapter.IPv4Enabled) { @@ -164,7 +170,9 @@ function Set-TargetResource $Name, $Protocol, $($netAdapter.IPv4Enabled.ToString()), $($State.ToString()) ) ) -join '') - Set-NetAdapterLso -Name $Name -IPv4Enabled $State + Set-NetAdapterLso ` + -Name $Name ` + -IPv4Enabled $State } elseif ($Protocol -eq 'IPv6' -and $State -ne $netAdapter.IPv6Enabled) { @@ -174,7 +182,9 @@ function Set-TargetResource $Name, $Protocol, $($netAdapter.IPv6Enabled.ToString()), $($State.ToString()) ) ) -join '') - Set-NetAdapterLso -Name $Name -IPv6Enabled $State + Set-NetAdapterLso ` + -Name $Name ` + -IPv6Enabled $State } } } @@ -219,7 +229,9 @@ function Test-TargetResource try { - $netAdapter = Get-NetAdapterLso -Name $Name -ErrorAction Stop + $netAdapter = Get-NetAdapterLso ` + -Name $Name ` + -ErrorAction Stop } catch { diff --git a/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.psm1 b/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.psm1 index cb61f390..bab3ad79 100644 --- a/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.psm1 +++ b/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.psm1 @@ -253,7 +253,8 @@ function Set-TargetResource $($script:localizedData.RenamingNetAdapterNameMessage -f $adapter.Name, $NewName) ) -join '') - $adapter | Rename-NetAdapter -NewName $NewName + $adapter | Rename-NetAdapter ` + -NewName $NewName Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " $($script:localizedData.NetAdapterNameRenamedMessage -f $NewName) diff --git a/source/DSCResources/DSC_NetAdapterRdma/DSC_NetAdapterRdma.psm1 b/source/DSCResources/DSC_NetAdapterRdma/DSC_NetAdapterRdma.psm1 index 26d4c3c1..bde6e762 100644 --- a/source/DSCResources/DSC_NetAdapterRdma/DSC_NetAdapterRdma.psm1 +++ b/source/DSCResources/DSC_NetAdapterRdma/DSC_NetAdapterRdma.psm1 @@ -37,7 +37,9 @@ function Get-TargetResource { Write-Verbose -Message ($script:localizedData.GetNetAdapterRdmaMessage -f $Name) - $netAdapterRdma = Get-NetAdapterRdma -Name $Name -ErrorAction Stop + $netAdapterRdma = Get-NetAdapterRdma ` + -Name $Name ` + -ErrorAction Stop } catch { @@ -85,7 +87,9 @@ function Set-TargetResource { Write-Verbose -Message ($script:localizedData.GetNetAdapterRdmaMessage -f $Name) - $netAdapterRdma = Get-NetAdapterRdma -Name $Name -ErrorAction Stop + $netAdapterRdma = Get-NetAdapterRdma ` + -Name $Name ` + -ErrorAction Stop } catch { @@ -101,7 +105,9 @@ function Set-TargetResource { Write-Verbose -Message ($script:localizedData.SetNetAdapterRdmaMessage -f $Name, $Enabled) - Set-NetAdapterRdma -Name $Name -Enabled $Enabled + Set-NetAdapterRdma ` + -Name $Name ` + -Enabled $Enabled } } } @@ -137,7 +143,9 @@ function Test-TargetResource { Write-Verbose -Message ($script:localizedData.GetNetAdapterRdmaMessage -f $Name) - $netAdapterRdma = Get-NetAdapterRdma -Name $Name -ErrorAction Stop + $netAdapterRdma = Get-NetAdapterRdma ` + -Name $Name ` + -ErrorAction Stop } catch { diff --git a/source/DSCResources/DSC_NetAdapterRsc/DSC_NetAdapterRsc.psm1 b/source/DSCResources/DSC_NetAdapterRsc/DSC_NetAdapterRsc.psm1 index 4246dc61..3bb5e429 100644 --- a/source/DSCResources/DSC_NetAdapterRsc/DSC_NetAdapterRsc.psm1 +++ b/source/DSCResources/DSC_NetAdapterRsc/DSC_NetAdapterRsc.psm1 @@ -50,7 +50,9 @@ function Get-TargetResource try { - $netAdapter = Get-NetAdapterRsc -Name $Name -ErrorAction Stop + $netAdapter = Get-NetAdapterRsc ` + -Name $Name ` + -ErrorAction Stop } catch { @@ -132,7 +134,9 @@ function Set-TargetResource try { - $netAdapter = Get-NetAdapterRsc -Name $Name -ErrorAction Stop + $netAdapter = Get-NetAdapterRsc ` + -Name $Name ` + -ErrorAction Stop } catch { @@ -155,7 +159,9 @@ function Set-TargetResource $Name, $Protocol, $($netAdapter.IPv4Enabled.ToString()), $($State.ToString()) ) ) -join '') - Set-NetAdapterRsc -Name $Name -IPv4Enabled $State + Set-NetAdapterRsc ` + -Name $Name ` + -IPv4Enabled $State } if ($Protocol -in ('IPv6', 'All') -and $State -ne $netAdapter.IPv6Enabled) { @@ -165,7 +171,9 @@ function Set-TargetResource $Name, $Protocol, $($netAdapter.IPv6Enabled.ToString()), $($State.ToString()) ) ) -join '') - Set-NetAdapterRsc -Name $Name -IPv6Enabled $State + Set-NetAdapterRsc ` + -Name $Name ` + -IPv6Enabled $State } } } @@ -210,7 +218,9 @@ function Test-TargetResource try { - $netAdapter = Get-NetAdapterRsc -Name $Name -ErrorAction Stop + $netAdapter = Get-NetAdapterRsc ` + -Name $Name ` + -ErrorAction Stop } catch { diff --git a/source/DSCResources/DSC_NetAdapterRss/DSC_NetAdapterRss.psm1 b/source/DSCResources/DSC_NetAdapterRss/DSC_NetAdapterRss.psm1 index 09b43f9d..3e5508c0 100644 --- a/source/DSCResources/DSC_NetAdapterRss/DSC_NetAdapterRss.psm1 +++ b/source/DSCResources/DSC_NetAdapterRss/DSC_NetAdapterRss.psm1 @@ -42,7 +42,9 @@ function Get-TargetResource try { - $netAdapter = Get-NetAdapterRss -Name $Name -ErrorAction Stop + $netAdapter = Get-NetAdapterRss ` + -Name $Name ` + -ErrorAction Stop } catch { @@ -97,7 +99,9 @@ function Set-TargetResource try { - $netAdapter = Get-NetAdapterRss -Name $Name -ErrorAction Stop + $netAdapter = Get-NetAdapterRss ` + -Name $Name ` + -ErrorAction Stop } catch { @@ -120,7 +124,9 @@ function Set-TargetResource $Name, $Enabled, $($netAdapter.Enabled.ToString()), $($Enabled.ToString()) ) ) -join '') - Set-NetAdapterRss -Name $Name -Enabled:$Enabled + Set-NetAdapterRss ` + -Name $Name ` + -Enabled:$Enabled } } } @@ -157,7 +163,9 @@ function Test-TargetResource try { - $netAdapter = Get-NetAdapterRss -Name $Name -ErrorAction Stop + $netAdapter = Get-NetAdapterRss ` + -Name $Name ` + -ErrorAction Stop } catch { diff --git a/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 b/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 index 1f14ea7a..793801e7 100644 --- a/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 +++ b/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 @@ -44,7 +44,9 @@ function Get-TargetResource try { - $netAdapter = Get-NetAdapter -Name $Name -ErrorAction Stop + $netAdapter = Get-NetAdapter ` + -Name $Name ` + -ErrorAction Stop } catch { @@ -115,7 +117,9 @@ function Set-TargetResource try { - $netAdapter = Get-NetAdapter -Name $Name -ErrorAction Stop + $netAdapter = Get-NetAdapter ` + -Name $Name ` + -ErrorAction Stop } catch { @@ -131,11 +135,16 @@ function Set-TargetResource { if ($State -eq 'Disabled') { - Disable-NetAdapter -Name $Name -Confirm:$false -ErrorAction Stop + Disable-NetAdapter ` + -Name $Name ` + -Confirm:$false ` + -ErrorAction Stop } else { - Enable-NetAdapter -Name $Name -ErrorAction Stop + Enable-NetAdapter ` + -Name $Name ` + -ErrorAction Stop } } catch diff --git a/source/DSCResources/DSC_NetBios/DSC_NetBios.psm1 b/source/DSCResources/DSC_NetBios/DSC_NetBios.psm1 index 5516aa0d..a0966063 100644 --- a/source/DSCResources/DSC_NetBios/DSC_NetBios.psm1 +++ b/source/DSCResources/DSC_NetBios/DSC_NetBios.psm1 @@ -92,7 +92,9 @@ function Get-TargetResource foreach ($netAdapterItem in $netAdapter) { - $settingResults += Get-NetAdapterNetbiosOptionsFromRegistry -NetworkAdapterGUID $netAdapterItem.GUID -Setting $Setting + $settingResults += Get-NetAdapterNetbiosOptionsFromRegistry ` + -NetworkAdapterGUID $netAdapterItem.GUID ` + -Setting $Setting Write-Verbose -Message ($script:localizedData.CurrentNetBiosSettingMessage -f $netAdapterItem.NetConnectionID, $settingResults[-1]) } @@ -108,7 +110,9 @@ function Get-TargetResource } else { - $Setting = Get-NetAdapterNetbiosOptionsFromRegistry -NetworkAdapterGUID $netAdapter.GUID -Setting $Setting + $Setting = Get-NetAdapterNetbiosOptionsFromRegistry ` + -NetworkAdapterGUID $netAdapter.GUID ` + -Setting $Setting } Write-Verbose -Message ($script:localizedData.CurrentNetBiosSettingMessage -f $InterfaceAlias, $Setting) @@ -167,7 +171,9 @@ function Set-TargetResource { foreach ($netAdapterItem in $netAdapter) { - $currentValue = Get-NetAdapterNetbiosOptionsFromRegistry -NetworkAdapterGUID $netAdapterItem.GUID -Setting $Setting + $currentValue = Get-NetAdapterNetbiosOptionsFromRegistry ` + -NetworkAdapterGUID $netAdapterItem.GUID ` + -Setting $Setting # Only make changes if necessary if ($currentValue -ne $Setting) @@ -178,9 +184,10 @@ function Set-TargetResource -ResultClassName Win32_NetworkAdapterConfiguration ` -ErrorAction Stop - Set-NetAdapterNetbiosOptions -NetworkAdapterObject $netAdapterConfig ` - -InterfaceAlias $netAdapterItem.NetConnectionID ` - -Setting $Setting + Set-NetAdapterNetbiosOptions ` + -NetworkAdapterObject $netAdapterConfig ` + -InterfaceAlias $netAdapterItem.NetConnectionID ` + -Setting $Setting } } } @@ -192,9 +199,10 @@ function Set-TargetResource -ResultClassName Win32_NetworkAdapterConfiguration ` -ErrorAction Stop - Set-NetAdapterNetbiosOptions -NetworkAdapterObject $netAdapterConfig ` - -InterfaceAlias $netAdapter.NetConnectionID ` - -Setting $Setting + Set-NetAdapterNetbiosOptions ` + -NetworkAdapterObject $netAdapterConfig ` + -InterfaceAlias $netAdapter.NetConnectionID ` + -Setting $Setting } } @@ -269,8 +277,9 @@ function Get-NetAdapterNetbiosOptionsFromRegistry $currentErrorActionPreference = $ErrorActionPreference $ErrorActionPreference = 'SilentlyContinue' - $registryNetbiosOptions = Get-ItemPropertyValue -Name 'NetbiosOptions' ` - -Path "$($script:hklmInterfacesPath)\Tcpip_$($NetworkAdapterGUID)" + $registryNetbiosOptions = Get-ItemPropertyValue ` + -Name 'NetbiosOptions' ` + -Path "$($script:hklmInterfacesPath)\Tcpip_$($NetworkAdapterGUID)" $ErrorActionPreference = $currentErrorActionPreference diff --git a/source/DSCResources/DSC_NetConnectionProfile/DSC_NetConnectionProfile.psm1 b/source/DSCResources/DSC_NetConnectionProfile/DSC_NetConnectionProfile.psm1 index 9f9144aa..cef402d1 100644 --- a/source/DSCResources/DSC_NetConnectionProfile/DSC_NetConnectionProfile.psm1 +++ b/source/DSCResources/DSC_NetConnectionProfile/DSC_NetConnectionProfile.psm1 @@ -32,7 +32,8 @@ function Get-TargetResource $($script:localizedData.GettingNetConnectionProfile) -f $InterfaceAlias ) -join '') - $result = Get-NetConnectionProfile -InterfaceAlias $InterfaceAlias + $result = Get-NetConnectionProfile ` + -InterfaceAlias $InterfaceAlias return @{ InterfaceAlias = $result.InterfaceAlias @@ -136,7 +137,8 @@ function Test-TargetResource Assert-ResourceProperty @PSBoundParameters - $current = Get-TargetResource -InterfaceAlias $InterfaceAlias + $current = Get-TargetResource ` + -InterfaceAlias $InterfaceAlias if (-not [System.String]::IsNullOrEmpty($IPv4Connectivity) -and ` ($IPv4Connectivity -ne $current.IPv4Connectivity)) diff --git a/source/DSCResources/DSC_NetIPInterface/DSC_NetIPInterface.psm1 b/source/DSCResources/DSC_NetIPInterface/DSC_NetIPInterface.psm1 index 5cb3caad..6ed8ba67 100644 --- a/source/DSCResources/DSC_NetIPInterface/DSC_NetIPInterface.psm1 +++ b/source/DSCResources/DSC_NetIPInterface/DSC_NetIPInterface.psm1 @@ -484,7 +484,8 @@ function Get-NetworkIPInterface $($script:localizedData.GettingNetIPInterfaceMessage) -f $InterfaceAlias, $AddressFamily ) -join '') - $netIPInterface = Get-NetIPInterface @PSBoundParameters -ErrorAction SilentlyContinue + $netIPInterface = Get-NetIPInterface @PSBoundParameters ` + -ErrorAction SilentlyContinue if (-not $netIPInterface) { diff --git a/source/DSCResources/DSC_NetworkTeam/DSC_NetworkTeam.psm1 b/source/DSCResources/DSC_NetworkTeam/DSC_NetworkTeam.psm1 index c533558c..a33653ff 100644 --- a/source/DSCResources/DSC_NetworkTeam/DSC_NetworkTeam.psm1 +++ b/source/DSCResources/DSC_NetworkTeam/DSC_NetworkTeam.psm1 @@ -43,7 +43,9 @@ function Get-TargetResource } Write-Verbose -Message ($script:localizedData.GetTeamInfo -f $Name) - $networkTeam = Get-NetLBFOTeam -Name $Name -ErrorAction SilentlyContinue + $networkTeam = Get-NetLBFOTeam ` + -Name $Name ` + -ErrorAction SilentlyContinue if ($networkTeam) { @@ -121,7 +123,9 @@ function Set-TargetResource Write-Verbose -Message ($script:localizedData.GetTeamInfo -f $Name) - $networkTeam = Get-NetLBFOTeam -Name $Name -ErrorAction SilentlyContinue + $networkTeam = Get-NetLBFOTeam ` + -Name $Name ` + -ErrorAction SilentlyContinue if ($Ensure -eq 'Present') { @@ -153,7 +157,9 @@ function Set-TargetResource { Write-Verbose -Message ($script:localizedData.ModifyTeam -f $Name) - Set-NetLbfoTeam @setArguments -ErrorAction Stop -Confirm:$false + Set-NetLbfoTeam @setArguments ` + -ErrorAction Stop ` + -Confirm:$false } $netTeamMembers = Compare-Object ` @@ -172,7 +178,8 @@ function Set-TargetResource { Write-Verbose -Message ($script:localizedData.RemovingMembers -f ($membersToRemove -join ',')) - $null = Remove-NetLbfoTeamMember -Name $membersToRemove ` + $null = Remove-NetLbfoTeamMember ` + -Name $membersToRemove ` -Team $Name ` -ErrorAction Stop ` -Confirm:$false @@ -186,7 +193,8 @@ function Set-TargetResource { Write-Verbose -Message ($script:localizedData.AddingMembers -f ($membersToAdd -join ',')) - $null = Add-NetLbfoTeamMember -Name $membersToAdd ` + $null = Add-NetLbfoTeamMember ` + -Name $membersToAdd ` -Team $Name ` -ErrorAction Stop ` -Confirm:$false @@ -221,7 +229,10 @@ function Set-TargetResource { Write-Verbose -Message ($script:localizedData.RemoveTeam -f $Name) - $null = Remove-NetLbfoTeam -Name $name -ErrorAction Stop -Confirm:$false + $null = Remove-NetLbfoTeam ` + -Name $name ` + -ErrorAction Stop ` + -Confirm:$false } } @@ -277,7 +288,9 @@ function Test-TargetResource Write-Verbose -Message ($script:localizedData.GetTeamInfo -f $Name) - $networkTeam = Get-NetLbfoTeam -Name $Name -ErrorAction SilentlyContinue + $networkTeam = Get-NetLbfoTeam ` + -Name $Name ` + -ErrorAction SilentlyContinue if ($ensure -eq 'Present') { diff --git a/source/DSCResources/DSC_ProxySettings/DSC_ProxySettings.psm1 b/source/DSCResources/DSC_ProxySettings/DSC_ProxySettings.psm1 index a9472a81..9541a380 100644 --- a/source/DSCResources/DSC_ProxySettings/DSC_ProxySettings.psm1 +++ b/source/DSCResources/DSC_ProxySettings/DSC_ProxySettings.psm1 @@ -60,7 +60,8 @@ function Get-TargetResource { $returnValue.Add('Ensure','Present') - $proxySettings = ConvertFrom-ProxySettingsBinary -ProxySettings $proxySettingsRegistryBinary + $proxySettings = ConvertFrom-ProxySettingsBinary ` + -ProxySettings $proxySettingsRegistryBinary $returnValue.Add('EnableManualProxy',$proxySettings.EnableManualProxy) $returnValue.Add('EnableAutoConfiguration',$proxySettings.EnableAutoConfiguration) @@ -392,14 +393,17 @@ function Test-TargetResource if ($connectionsRegistryValues.DefaultConnectionSettings) { - $defaultConnectionSettings = ConvertFrom-ProxySettingsBinary -ProxySettings $connectionsRegistryValues.DefaultConnectionSettings + $defaultConnectionSettings = ConvertFrom-ProxySettingsBinary ` + -ProxySettings $connectionsRegistryValues.DefaultConnectionSettings } else { $defaultConnectionSettings = @{} } - $inDesiredState = Test-ProxySettings -CurrentValues $defaultConnectionSettings -DesiredValues $desiredValues + $inDesiredState = Test-ProxySettings ` + -CurrentValues $defaultConnectionSettings ` + -DesiredValues $desiredValues if (-not $inDesiredState) { @@ -420,14 +424,17 @@ function Test-TargetResource if ($connectionsRegistryValues.SavedLegacySettings) { - $savedLegacySettings = ConvertFrom-ProxySettingsBinary -ProxySettings $connectionsRegistryValues.SavedLegacySettings + $savedLegacySettings = ConvertFrom-ProxySettingsBinary ` + -ProxySettings $connectionsRegistryValues.SavedLegacySettings } else { $savedLegacySettings = @{} } - $inDesiredState = Test-ProxySettings -CurrentValues $savedLegacySettings -DesiredValues $desiredValues + $inDesiredState = Test-ProxySettings ` + -CurrentValues $savedLegacySettings ` + -DesiredValues $desiredValues if (-not $inDesiredState) { @@ -792,7 +799,9 @@ function ConvertFrom-ProxySettingsBinary # Extract the Proxy Server string $proxyServer = '' - $stringLength = Get-Int32FromByteArray -Byte $ProxySettings -StartByte $stringPointer + $stringLength = Get-Int32FromByteArray ` + -Byte $ProxySettings ` + -StartByte $stringPointer $stringPointer += 4 if ($stringLength -gt 0) @@ -807,7 +816,9 @@ function ConvertFrom-ProxySettingsBinary # Extract the Proxy Server Exceptions string $proxyServerExceptions = @() - $stringLength = Get-Int32FromByteArray -Byte $ProxySettings -StartByte $stringPointer + $stringLength = Get-Int32FromByteArray ` + -Byte $ProxySettings ` + -StartByte $stringPointer $stringPointer += 4 if ($stringLength -gt 0) diff --git a/source/DSCResources/DSC_WinsServerAddress/DSC_WinsServerAddress.psm1 b/source/DSCResources/DSC_WinsServerAddress/DSC_WinsServerAddress.psm1 index e8598e34..6951523d 100644 --- a/source/DSCResources/DSC_WinsServerAddress/DSC_WinsServerAddress.psm1 +++ b/source/DSCResources/DSC_WinsServerAddress/DSC_WinsServerAddress.psm1 @@ -77,7 +77,10 @@ function Set-TargetResource Write-Verbose -Message "$($MyInvocation.MyCommand): $($script:localizedData.ApplyingWinsServerAddressesMessage)" - Set-WinsClientServerStaticAddress -InterfaceAlias $InterfaceAlias -Address $Address -ErrorAction Stop + Set-WinsClientServerStaticAddress ` + -InterfaceAlias $InterfaceAlias ` + -Address $Address ` + -ErrorAction Stop } diff --git a/source/Modules/NetworkingDsc.Common/NetworkingDsc.Common.psm1 b/source/Modules/NetworkingDsc.Common/NetworkingDsc.Common.psm1 index 189754ce..0b71bc8e 100644 --- a/source/Modules/NetworkingDsc.Common/NetworkingDsc.Common.psm1 +++ b/source/Modules/NetworkingDsc.Common/NetworkingDsc.Common.psm1 @@ -396,7 +396,9 @@ function Get-WinsClientServerStaticAddress Write-Verbose -Message ("$($MyInvocation.MyCommand): $($script:localizedData.GettingWinsServerStaticAddressMessage -f $InterfaceAlias)") # Look up the interface Guid - $adapter = Get-NetAdapter -InterfaceAlias $InterfaceAlias -ErrorAction SilentlyContinue + $adapter = Get-NetAdapter ` + -InterfaceAlias $InterfaceAlias ` + -ErrorAction SilentlyContinue if (-not $adapter) { @@ -458,7 +460,9 @@ function Set-WinsClientServerStaticAddress Write-Verbose -Message ("$($MyInvocation.MyCommand): $($script:localizedData.SettingWinsServerStaticAddressMessage -f $InterfaceAlias, ($Address -join ', '))") # Look up the interface Guid - $adapter = Get-NetAdapter -InterfaceAlias $InterfaceAlias -ErrorAction SilentlyContinue + $adapter = Get-NetAdapter ` + -InterfaceAlias $InterfaceAlias ` + -ErrorAction SilentlyContinue if (-not $adapter) { From 0572312b2882b42f872db7abb3cec082deb562f9 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Wed, 19 May 2021 22:54:55 -0400 Subject: [PATCH 03/20] Minor code style reformatting. Minor reformatting of code style. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47fe5f28..ca6e7ead 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated build to use `Sampler.GitHubTasks` - Fixes [Issue #489](https://github.com/dsccommunity/NetworkingDsc/issues/489). - Added support for publishing code coverage to `CodeCov.io` and Azure Pipelines - Fixes [Issue #491](https://github.com/dsccommunity/NetworkingDsc/issues/491). +- Minor reformatting of code style for diffability. ## [8.2.0] - 2020-10-16 From a219b1f9c0e6e874647714884543e830edb92602 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Wed, 19 May 2021 21:37:44 -0400 Subject: [PATCH 04/20] Reformat whitespace for diffability to match other modues --- .../DSC_FirewallProfile/DSC_FirewallProfile.psm1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/DSCResources/DSC_FirewallProfile/DSC_FirewallProfile.psm1 b/source/DSCResources/DSC_FirewallProfile/DSC_FirewallProfile.psm1 index 1a05d3a9..debc49d5 100644 --- a/source/DSCResources/DSC_FirewallProfile/DSC_FirewallProfile.psm1 +++ b/source/DSCResources/DSC_FirewallProfile/DSC_FirewallProfile.psm1 @@ -245,7 +245,10 @@ function Set-TargetResource $parameterNewValue = (Get-Variable -Name ($parameter.name)).Value if ($PSBoundParameters.ContainsKey($parameter.Name) ` - -and (Compare-Object -ReferenceObject $parameterSourceValue -DifferenceObject $parameterNewValue -SyncWindow 0)) + -and (Compare-Object ` + -ReferenceObject $parameterSourceValue ` + -DifferenceObject $parameterNewValue ` + -SyncWindow 0)) { $changeParameters += @{ $($parameter.name) = $parameterNewValue From 25b88a3cf861b322792fda94dd8fa6bd44b0758e Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 16:18:20 -0400 Subject: [PATCH 05/20] Find-NetworkAdapter: add -IncludeHidden parameter Add -IncludeHidden parameter to helper function Find-NetworkAdapter with default to $true --- .../NetworkingDsc.Common.psm1 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/source/Modules/NetworkingDsc.Common/NetworkingDsc.Common.psm1 b/source/Modules/NetworkingDsc.Common/NetworkingDsc.Common.psm1 index 0b71bc8e..7e0d2c86 100644 --- a/source/Modules/NetworkingDsc.Common/NetworkingDsc.Common.psm1 +++ b/source/Modules/NetworkingDsc.Common/NetworkingDsc.Common.psm1 @@ -97,6 +97,9 @@ function Convert-CIDRToSubhetMask .PARAMETER InterfaceDescription This is the interface description of the network adapter to find. + .PARAMETER IncludeHidden + This switch indicates the adapter to find may be hidden. + .PARAMETER InterfaceIndex This is the interface index of the network adapter to find. @@ -142,6 +145,10 @@ function Find-NetworkAdapter [System.String] $InterfaceDescription, + [Parameter()] + [System.Boolean] + $IncludeHidden = $true, + [Parameter()] [System.UInt32] $InterfaceIndex, @@ -215,13 +222,13 @@ function Find-NetworkAdapter $($script:localizedData.AllNetAdaptersFoundMessage) ) -join '') - $matchingAdapters = @(Get-NetAdapter) + $matchingAdapters = @(Get-NetAdapter -IncludeHidden:$IncludeHidden) } else { # Join all the filters together $adapterFilterScript = '(' + ($adapterFilters -join ' -and ') + ')' - $matchingAdapters = @(Get-NetAdapter | + $matchingAdapters = @(Get-NetAdapter -IncludeHidden:$IncludeHidden | Where-Object -FilterScript ([ScriptBlock]::Create($adapterFilterScript))) } @@ -276,6 +283,7 @@ function Find-NetworkAdapter Status = $exactAdapter.Status MacAddress = $exactAdapter.MacAddress InterfaceDescription = $exactAdapter.InterfaceDescription + IncludeHidden = $IncludeHidden InterfaceIndex = $exactAdapter.InterfaceIndex InterfaceGuid = $exactAdapter.InterfaceGuid MatchingAdapterCount = $matchingAdapters.Count @@ -323,6 +331,7 @@ function Get-DnsClientServerStaticAddress # Look up the interface Guid $adapter = Get-NetAdapter ` -InterfaceAlias $InterfaceAlias ` + -IncludeHidden:$true ` -ErrorAction SilentlyContinue if (-not $adapter) @@ -398,6 +407,7 @@ function Get-WinsClientServerStaticAddress # Look up the interface Guid $adapter = Get-NetAdapter ` -InterfaceAlias $InterfaceAlias ` + -IncludeHidden:$true ` -ErrorAction SilentlyContinue if (-not $adapter) @@ -462,6 +472,7 @@ function Set-WinsClientServerStaticAddress # Look up the interface Guid $adapter = Get-NetAdapter ` -InterfaceAlias $InterfaceAlias ` + -IncludeHidden:$true ` -ErrorAction SilentlyContinue if (-not $adapter) From bf6235a1ee46774e243cae9045ac7a39094fc946 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 16:20:23 -0400 Subject: [PATCH 06/20] NetAdapterName: add IncludeHidden property Add IncludeHidden property to NetAdapterName resource, defaulting to $false --- .../DSC_NetAdapterName.psm1 | 25 +++++++++++++++++++ .../DSC_NetAdapterName.schema.mof | 1 + 2 files changed, 26 insertions(+) diff --git a/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.psm1 b/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.psm1 index bab3ad79..165af86c 100644 --- a/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.psm1 +++ b/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.psm1 @@ -33,6 +33,9 @@ $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' .PARAMETER InterfaceDescription This is the interface description of the network adapter to find. + .PARAMETER IncludeHidden + This switch indicates the adapter to find may be hidden. + .PARAMETER InterfaceIndex This is the interface index of the network adapter to find. @@ -84,6 +87,10 @@ function Get-TargetResource [System.String] $InterfaceDescription, + [Parameter()] + [System.Boolean] + $IncludeHidden = $false, + [Parameter()] [System.UInt32] $InterfaceIndex, @@ -111,6 +118,7 @@ function Get-TargetResource $adapter = Find-NetworkAdapter ` -Name $NewName ` + -IncludeHidden:$IncludeHidden ` -ErrorAction SilentlyContinue if (-not $adapter) @@ -136,6 +144,7 @@ function Get-TargetResource Status = $adapter.Status MacAddress = $adapter.MacAddress InterfaceDescription = $adapter.InterfaceDescription + IncludeHidden = $IncludeHidden InterfaceIndex = $adapter.InterfaceIndex InterfaceGuid = $adapter.InterfaceGuid DriverDescription = $adapter.DriverDescription @@ -168,6 +177,9 @@ function Get-TargetResource .PARAMETER InterfaceDescription This is the interface description of the network adapter to find. + .PARAMETER IncludeHidden + This switch indicates the adapter to find may be hidden. + .PARAMETER InterfaceIndex This is the interface index of the network adapter to find. @@ -218,6 +230,10 @@ function Set-TargetResource [System.String] $InterfaceDescription, + [Parameter()] + [System.Boolean] + $IncludeHidden = $false, + [Parameter()] [System.UInt32] $InterfaceIndex, @@ -254,6 +270,7 @@ function Set-TargetResource ) -join '') $adapter | Rename-NetAdapter ` + -IncludeHidden:$IncludeHidden ` -NewName $NewName Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " @@ -284,6 +301,9 @@ function Set-TargetResource .PARAMETER InterfaceDescription This is the interface description of the network adapter to find. + .PARAMETER IncludeHidden + This switch indicates the adapter to find may be hidden. + .PARAMETER InterfaceIndex This is the interface index of the network adapter to find. @@ -335,6 +355,10 @@ function Test-TargetResource [System.String] $InterfaceDescription, + [Parameter()] + [System.Boolean] + $IncludeHidden = $false, + [Parameter()] [System.UInt32] $InterfaceIndex, @@ -365,6 +389,7 @@ function Test-TargetResource # Can an adapter be found with the new name? $adapterWithNewName = Find-NetworkAdapter ` -Name $NewName ` + -IncludeHidden:$IncludeHidden ` -Verbose:$Verbose ` -ErrorAction SilentlyContinue diff --git a/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.schema.mof b/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.schema.mof index aa27f022..05f5d6f5 100644 --- a/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.schema.mof +++ b/source/DSCResources/DSC_NetAdapterName/DSC_NetAdapterName.schema.mof @@ -7,6 +7,7 @@ class DSC_NetAdapterName : OMI_BaseResource [Write, Description("This is the status of the network adapter to find."), ValueMap{"Up", "Disconnected", "Disabled"}, Values{"Up", "Disconnected", "Disabled"}] String Status; [Write, Description("This is the MAC address of the network adapter to find.")] String MacAddress; [Write, Description("This is the interface description of the network adapter to find.")] String InterfaceDescription; + [Write, Description("This switch indicates the adapter to find may be hidden.")] Boolean IncludeHidden; [Write, Description("This is the interface index of the network adapter to find.")] UInt32 InterfaceIndex; [Write, Description("This is the interface GUID of the network adapter to find.")] String InterfaceGuid; [Write, Description("This is the driver description of the network adapter.")] String DriverDescription; From ed1227c2b42bb898e921a7a4f469c33374a22980 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 16:24:41 -0400 Subject: [PATCH 07/20] DefaultGatewayAddress: use Find-NetworkAdapter In Assert-ResourceProperty, use Find-NetworkAdapter instead of Get-NetAdapter. --- .../DSC_DefaultGatewayAddress/DSC_DefaultGatewayAddress.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/DSCResources/DSC_DefaultGatewayAddress/DSC_DefaultGatewayAddress.psm1 b/source/DSCResources/DSC_DefaultGatewayAddress/DSC_DefaultGatewayAddress.psm1 index d1034729..142c3110 100644 --- a/source/DSCResources/DSC_DefaultGatewayAddress/DSC_DefaultGatewayAddress.psm1 +++ b/source/DSCResources/DSC_DefaultGatewayAddress/DSC_DefaultGatewayAddress.psm1 @@ -292,7 +292,7 @@ function Assert-ResourceProperty $Address ) - if (-not (Get-NetAdapter | Where-Object -Property Name -EQ $InterfaceAlias )) + if (-not (Find-NetworkAdapter -Name $InterfaceAlias )) { New-InvalidOperationException ` -Message ($script:localizedData.InterfaceNotAvailableError -f $InterfaceAlias) From fba847519dc3d44b903f160391d6c17ec348d422 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 16:34:49 -0400 Subject: [PATCH 08/20] NetAdapterAdvancedProperty: include hidden adapters Add -IncludeHidden:$true for all calls to *-NetAdapterAdvancedProperty --- .../DSC_NetAdapterAdvancedProperty.psm1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/DSCResources/DSC_NetAdapterAdvancedProperty/DSC_NetAdapterAdvancedProperty.psm1 b/source/DSCResources/DSC_NetAdapterAdvancedProperty/DSC_NetAdapterAdvancedProperty.psm1 index b9034af5..a4672c3d 100644 --- a/source/DSCResources/DSC_NetAdapterAdvancedProperty/DSC_NetAdapterAdvancedProperty.psm1 +++ b/source/DSCResources/DSC_NetAdapterAdvancedProperty/DSC_NetAdapterAdvancedProperty.psm1 @@ -51,6 +51,7 @@ function Get-TargetResource { $netAdapterAdvancedProperty = Get-NetAdapterAdvancedProperty ` -Name $networkAdapterName ` + -IncludeHidden:$true ` -RegistryKeyword $RegistryKeyword ` -ErrorAction Stop } @@ -118,6 +119,7 @@ function Set-TargetResource { $netAdapterAdvancedProperty = Get-NetAdapterAdvancedProperty ` -Name $networkAdapterName ` + -IncludeHidden:$true ` -RegistryKeyword $RegistryKeyword ` -ErrorAction Stop } @@ -146,6 +148,7 @@ function Set-TargetResource Set-NetAdapterAdvancedProperty ` -RegistryValue $RegistryValue ` -Name $networkAdapterName ` + -IncludeHidden:$true ` -RegistryKeyword $RegistryKeyword } } @@ -192,6 +195,7 @@ function Test-TargetResource { $netAdapterAdvancedProperty = Get-NetAdapterAdvancedProperty ` -Name $networkAdapterName ` + -IncludeHidden:$true ` -RegistryKeyword $RegistryKeyword ` -ErrorAction Stop } From d24c9233758bdb868df72be0c6ccaacc7363feee Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 16:36:17 -0400 Subject: [PATCH 09/20] NetAdapterBinding: include hidden adapters Add -IncludeHidden:$true to calls to *-NetAdapterBinding --- .../DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1 b/source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1 index b57d30d4..52349898 100644 --- a/source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1 +++ b/source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1 @@ -126,7 +126,8 @@ function Set-TargetResource if ($State -eq 'Enabled') { - Enable-NetAdapterBinding @PSBoundParameters + Enable-NetAdapterBinding @PSBoundParameters ` + -IncludeHidden:$true Write-Verbose -Message ( @("$($MyInvocation.MyCommand): " $($script:localizedData.NetAdapterBindingEnabledMessage -f ` @@ -135,7 +136,8 @@ function Set-TargetResource } else { - Disable-NetAdapterBinding @PSBoundParameters + Disable-NetAdapterBinding @PSBoundParameters ` + -IncludeHidden:$true Write-Verbose -Message ( @("$($MyInvocation.MyCommand): " $($script:localizedData.NetAdapterBindingDisabledMessage -f ` @@ -269,6 +271,7 @@ function Get-Binding $binding = Get-NetAdapterBinding ` -InterfaceAlias $InterfaceAlias ` + -IncludeHidden:$true ` -ComponentId $ComponentId ` -ErrorAction Stop From fde27137222d49b1dfbc9241e27a3fac10e1a226 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 16:42:08 -0400 Subject: [PATCH 10/20] NetAdapterbinding: use Find-NetworkAdapter In Get-Binding, use Find-NetworkAdapter instead of Get-NetAdapter. --- .../DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1 b/source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1 index 52349898..4defa939 100644 --- a/source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1 +++ b/source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1 @@ -262,7 +262,7 @@ function Get-Binding $State = 'Enabled' ) - if (-not (Get-NetAdapter -Name $InterfaceAlias -ErrorAction SilentlyContinue)) + if (-not (Find-NetworkAdapter -Name $InterfaceAlias -ErrorAction SilentlyContinue)) { New-InvalidArgumentException ` -Message ($script:localizedData.InterfaceNotAvailableError -f $InterfaceAlias) ` From ab3a323e0b41f220212b18a19300904bb21b6a84 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 17:07:13 -0400 Subject: [PATCH 11/20] NetAdapterLso: include hidden adapters Add -IncludeHidden:$true to calls of *-NetAdapterLso --- .../DSCResources/DSC_NetAdapterLso/DSC_NetAdapterLso.psm1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/DSCResources/DSC_NetAdapterLso/DSC_NetAdapterLso.psm1 b/source/DSCResources/DSC_NetAdapterLso/DSC_NetAdapterLso.psm1 index c8feece8..6dd23a0b 100644 --- a/source/DSCResources/DSC_NetAdapterLso/DSC_NetAdapterLso.psm1 +++ b/source/DSCResources/DSC_NetAdapterLso/DSC_NetAdapterLso.psm1 @@ -52,6 +52,7 @@ function Get-TargetResource { $netAdapter = Get-NetAdapterLso ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } catch @@ -135,6 +136,7 @@ function Set-TargetResource { $netAdapter = Get-NetAdapterLso ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } catch @@ -160,6 +162,7 @@ function Set-TargetResource Set-NetAdapterLso ` -Name $Name ` + -IncludeHidden:$true ` -V1IPv4Enabled $State } elseif ($Protocol -eq 'IPv4' -and $State -ne $netAdapter.IPv4Enabled) @@ -172,6 +175,7 @@ function Set-TargetResource Set-NetAdapterLso ` -Name $Name ` + -IncludeHidden:$true ` -IPv4Enabled $State } elseif ($Protocol -eq 'IPv6' -and $State -ne $netAdapter.IPv6Enabled) @@ -184,6 +188,7 @@ function Set-TargetResource Set-NetAdapterLso ` -Name $Name ` + -IncludeHidden:$true ` -IPv6Enabled $State } } @@ -231,6 +236,7 @@ function Test-TargetResource { $netAdapter = Get-NetAdapterLso ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } catch From 5708b0394191e13878b6ef69e75dc948e478cbc6 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 17:08:31 -0400 Subject: [PATCH 12/20] NetAdapterRdma: include hidden adapeters Add -IncludeHidden:$true to calls of *-NetAdapterRdma --- source/DSCResources/DSC_NetAdapterRdma/DSC_NetAdapterRdma.psm1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/DSCResources/DSC_NetAdapterRdma/DSC_NetAdapterRdma.psm1 b/source/DSCResources/DSC_NetAdapterRdma/DSC_NetAdapterRdma.psm1 index bde6e762..d5bc6421 100644 --- a/source/DSCResources/DSC_NetAdapterRdma/DSC_NetAdapterRdma.psm1 +++ b/source/DSCResources/DSC_NetAdapterRdma/DSC_NetAdapterRdma.psm1 @@ -39,6 +39,7 @@ function Get-TargetResource $netAdapterRdma = Get-NetAdapterRdma ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } catch @@ -89,6 +90,7 @@ function Set-TargetResource $netAdapterRdma = Get-NetAdapterRdma ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } catch @@ -107,6 +109,7 @@ function Set-TargetResource Set-NetAdapterRdma ` -Name $Name ` + -IncludeHidden:$true ` -Enabled $Enabled } } From 92871152e15af2a872b4d4e4b549bd70effb17ee Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 17:09:24 -0400 Subject: [PATCH 13/20] NetAdapterRsc: include hidden adapters Add -IncludeHidden:$true on calls to *-NetAdapterRsc --- source/DSCResources/DSC_NetAdapterRsc/DSC_NetAdapterRsc.psm1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/DSCResources/DSC_NetAdapterRsc/DSC_NetAdapterRsc.psm1 b/source/DSCResources/DSC_NetAdapterRsc/DSC_NetAdapterRsc.psm1 index 3bb5e429..bfe8c042 100644 --- a/source/DSCResources/DSC_NetAdapterRsc/DSC_NetAdapterRsc.psm1 +++ b/source/DSCResources/DSC_NetAdapterRsc/DSC_NetAdapterRsc.psm1 @@ -52,6 +52,7 @@ function Get-TargetResource { $netAdapter = Get-NetAdapterRsc ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } catch @@ -136,6 +137,7 @@ function Set-TargetResource { $netAdapter = Get-NetAdapterRsc ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } catch @@ -161,6 +163,7 @@ function Set-TargetResource Set-NetAdapterRsc ` -Name $Name ` + -IncludeHidden:$true ` -IPv4Enabled $State } if ($Protocol -in ('IPv6', 'All') -and $State -ne $netAdapter.IPv6Enabled) @@ -173,6 +176,7 @@ function Set-TargetResource Set-NetAdapterRsc ` -Name $Name ` + -IncludeHidden:$true ` -IPv6Enabled $State } } @@ -220,6 +224,7 @@ function Test-TargetResource { $netAdapter = Get-NetAdapterRsc ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } catch From caa645d61343fbee02b68a8d0d540194f99c4baa Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 17:10:03 -0400 Subject: [PATCH 14/20] NetAdapterRss: include hidden adapters Add -IncludeHidden:$true on calls to *-NetAdapterRss --- source/DSCResources/DSC_NetAdapterRss/DSC_NetAdapterRss.psm1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/DSCResources/DSC_NetAdapterRss/DSC_NetAdapterRss.psm1 b/source/DSCResources/DSC_NetAdapterRss/DSC_NetAdapterRss.psm1 index 3e5508c0..eb438c02 100644 --- a/source/DSCResources/DSC_NetAdapterRss/DSC_NetAdapterRss.psm1 +++ b/source/DSCResources/DSC_NetAdapterRss/DSC_NetAdapterRss.psm1 @@ -44,6 +44,7 @@ function Get-TargetResource { $netAdapter = Get-NetAdapterRss ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } catch @@ -101,6 +102,7 @@ function Set-TargetResource { $netAdapter = Get-NetAdapterRss ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } catch @@ -126,6 +128,7 @@ function Set-TargetResource Set-NetAdapterRss ` -Name $Name ` + -IncludeHidden:$true ` -Enabled:$Enabled } } @@ -165,6 +168,7 @@ function Test-TargetResource { $netAdapter = Get-NetAdapterRss ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } catch From 586ccc8d0179ae1228c00e59ef0b679f97d636f2 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 17:13:31 -0400 Subject: [PATCH 15/20] NetAdapterState: use Find-NetworkAdapter In Get/Set-TargetResource, use Find-NetworkAdapter instead of Get-NetAdapter --- .../DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 b/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 index 793801e7..0273a69e 100644 --- a/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 +++ b/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 @@ -44,7 +44,7 @@ function Get-TargetResource try { - $netAdapter = Get-NetAdapter ` + $netAdapter = Find-NetworkAdapter ` -Name $Name ` -ErrorAction Stop } @@ -117,7 +117,7 @@ function Set-TargetResource try { - $netAdapter = Get-NetAdapter ` + $netAdapter = Find-NetworkAdapter ` -Name $Name ` -ErrorAction Stop } From d89ec2eabf85eda187217f104f437c44d8b4d39c Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 17:14:46 -0400 Subject: [PATCH 16/20] NetAdapterState: include hidden adapters Add -IncludeHidden:$true on calls to *-NetAdapter --- .../DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 b/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 index 0273a69e..80d916a0 100644 --- a/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 +++ b/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 @@ -137,6 +137,7 @@ function Set-TargetResource { Disable-NetAdapter ` -Name $Name ` + -IncludeHidden:$true ` -Confirm:$false ` -ErrorAction Stop } @@ -144,6 +145,7 @@ function Set-TargetResource { Enable-NetAdapter ` -Name $Name ` + -IncludeHidden:$true ` -ErrorAction Stop } } From 8ff8f5238963d685dd64afc80ef40bca949e0b9c Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 17:17:38 -0400 Subject: [PATCH 17/20] NetConnectionProfile: use Find-NetworkAdapter In Assert-ResourceProperty, use Find-NetworkAdapter instead of Get-NetAdapter --- .../DSC_NetConnectionProfile/DSC_NetConnectionProfile.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/DSCResources/DSC_NetConnectionProfile/DSC_NetConnectionProfile.psm1 b/source/DSCResources/DSC_NetConnectionProfile/DSC_NetConnectionProfile.psm1 index cef402d1..bd409093 100644 --- a/source/DSCResources/DSC_NetConnectionProfile/DSC_NetConnectionProfile.psm1 +++ b/source/DSCResources/DSC_NetConnectionProfile/DSC_NetConnectionProfile.psm1 @@ -216,7 +216,7 @@ function Assert-ResourceProperty $NetworkCategory ) - if (-not (Get-NetAdapter | Where-Object -Property Name -EQ $InterfaceAlias )) + if (-not (Find-NetworkAdapter -Name $InterfaceAlias )) { New-InvalidOperationException ` -Message ($script:localizedData.InterfaceNotAvailableError -f $InterfaceAlias) From 4f163126e01c10a67c676ba9a508230a4588387b Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 17:21:42 -0400 Subject: [PATCH 18/20] Route: use Find-NetworkAdapter In Assert-ResourceProperty, use Find-NetworkAdapter instead of Get-NetAdapter --- source/DSCResources/DSC_Route/DSC_Route.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/DSCResources/DSC_Route/DSC_Route.psm1 b/source/DSCResources/DSC_Route/DSC_Route.psm1 index fbdc1c24..47be08fe 100644 --- a/source/DSCResources/DSC_Route/DSC_Route.psm1 +++ b/source/DSCResources/DSC_Route/DSC_Route.psm1 @@ -613,7 +613,7 @@ function Assert-ResourceProperty ) # Validate the Adapter exists - if (-not (Get-NetAdapter | Where-Object -Property Name -EQ $InterfaceAlias )) + if (-not (Find-NetworkAdapter -Name $InterfaceAlias )) { New-InvalidArgumentException ` -Message $($($script:localizedData.InterfaceNotAvailableError) -f $InterfaceAlias) ` From 3c460891a2aecfd65869f892aa561d7cfbd01ad6 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 17:23:01 -0400 Subject: [PATCH 19/20] WinsServerAddress: use Find-NetworkAdapter In Assert-ResourceProperty, use Find-NetworkAdapter instead of Get-NetAdapter --- .../DSC_WinsServerAddress/DSC_WinsServerAddress.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/DSCResources/DSC_WinsServerAddress/DSC_WinsServerAddress.psm1 b/source/DSCResources/DSC_WinsServerAddress/DSC_WinsServerAddress.psm1 index 6951523d..29e90236 100644 --- a/source/DSCResources/DSC_WinsServerAddress/DSC_WinsServerAddress.psm1 +++ b/source/DSCResources/DSC_WinsServerAddress/DSC_WinsServerAddress.psm1 @@ -150,7 +150,7 @@ function Assert-ResourceProperty $Address ) - if (-not (Get-NetAdapter | Where-Object Name -EQ $InterfaceAlias)) + if (-not (Find-NetworkAdapter -Name $InterfaceAlias)) { New-InvalidArgumentException ` -Message ($script:localizedData.InterfaceNotAvailableError -f $InterfaceAlias) ` From c3df66c63032bc2f3d485e0aa8276aa52539ca2c Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 22 May 2021 18:08:43 -0400 Subject: [PATCH 20/20] Allow configuration of hidden network adapters. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca6e7ead..e1f237eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated build to use `Sampler.GitHubTasks` - Fixes [Issue #489](https://github.com/dsccommunity/NetworkingDsc/issues/489). - Added support for publishing code coverage to `CodeCov.io` and Azure Pipelines - Fixes [Issue #491](https://github.com/dsccommunity/NetworkingDsc/issues/491). -- Minor reformatting of code style for diffability. +- Allow configuration of hidden network adapters. ## [8.2.0] - 2020-10-16