66. NOTES
77 Author(s): Jonathan Conway
88 Modified: 23/04/2020
9- Version: 1.1
9+ Version: 1.2
1010#>
1111
1212Param (
@@ -218,7 +218,8 @@ function Get-HardwareInfo {
218218function Get-NetworkInfo {
219219
220220 (Get-CimInstance - ClassName ' Win32_NetworkAdapterConfiguration' - Filter ' IPEnabled = 1' ) | ForEach-Object {
221-
221+
222+ # Get IP address information
222223 $_.IPAddress | ForEach-Object {
223224 if ($_ -ne $null ) {
224225 if ($_.IndexOf (' .' ) -gt 0 -and ! $_.StartsWith (' 169.254' ) -and $_ -ne ' 0.0.0.0' ) {
@@ -233,6 +234,7 @@ function Get-NetworkInfo {
233234 }
234235 }
235236
237+ # Get Default Gateway information
236238 $_.DefaultIPGateway -split ' ,' | Select-Object - First ' 1' | ForEach-Object {
237239 if ($_ -ne $null -and $_.IndexOf (' .' ) -gt 0 ) {
238240
@@ -245,18 +247,21 @@ function Get-NetworkInfo {
245247 }
246248 }
247249
248- $EthernetConnection = Get-CimInstance - ClassName ' Win32_NetworkAdapter ' | Where-Object { $_ .Name -like " *Ethernet Connection* " -or $_ .Name -like " *Realtek PCIe* " -and $_ .NetConnectionStatus -eq ' 2 ' }
250+ }
249251
250- if ($null -eq $EthernetConnection ) {
251- $IsOnEthernet = $false
252- }
253- else {
254- $IsOnEthernet = $true
255- }
252+ # Check to see if the device is connected via Ethernet and return $true if it is
253+ $EthernetConnection = Get-CimInstance - ClassName ' Win32_NetworkAdapter' | Where-Object { $_.Name -like " *Ethernet Connection*" -or $_.Name -like " *Realtek PCIe*" -and $_.NetConnectionStatus -eq ' 2' }
256254
257- $TSvars.Add (' IsOnEthernet' , " $IsOnEthernet " )
255+ if ($null -eq $EthernetConnection ) {
256+ $IsOnEthernet = $false
257+ }
258+ else {
259+ $IsOnEthernet = $true
258260 }
261+
262+ $TSvars.Add (' IsOnEthernet' , " $IsOnEthernet " )
259263
264+ # Get device MAC addresses for conencted NICs
260265 $Nic = (Get-CimInstance - ClassName ' Win32_NetworkAdapter' - Filter ' NetConnectionStatus = 2' )
261266
262267 $TSvars.Add (' MacAddress' , $Nic.MACAddress -join ' ,' )
0 commit comments