The purpose of my code is to pull information from network cards on Windows hosts.
Unless I am mistaken, there is no built-in way of doing this. So what I want to do is to build a custom object.
The problem I am facing is that there are mutiple cards on different systems and I am not able to output the information in a human readable format for each property is an array.
$AdapterSpeed = @(Get-WmiObject Win32_NetworkAdapter | foreach-object {Get-WmiObject -namespace root/WMI -class MSNdis_LinkSpeed -filter "InstanceName='$($_.Name)'"} | Select-Object InstanceName,NdisLinkSpeed,Active)
$AdpaterProp = @(Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Select-Object -Property Description,DHCPEnabled,DHCPServer,DNSDomain,DNSServerSearchOrder,DefaultIPGateway)
# How can I create an array of propertie
$myCustomObject = New-Object -TypeName PSObject -Property @{
'Description' = $AdpaterProp.Description
'Speed' = $AdapterSpeed.NdisLinkSpeed
'DHCPEnabled' = $AdpaterProp.DHCPEnabled
'DHCPServer'= $AdpaterProp.DHCPServer
'DNSDomain'= $AdpaterProp.DNSDomain
'DNSServerSearchOrder'= $AdpaterProp.DNSServerSearchOrder
'DefaultIPGateway'= $AdpaterProp.DefaultIPGateway
}
What I would like to see is something like this:
Description: Intel(R) Dual Band Wireless-AC 8260
DHCPEnabled : True
DHCPServer : 10.0.0.20
DNSDomain : localhost.localdomain
DNSServerSearchOrder : {10.0.0.11, 10.0.0.12}
DefaultIPGateway : {10.0.0.1}
NdisLinkSpeed : 100000000
Active : True