Open VictorPavlushin opened 5 years ago
Hi @raspi any update on this issue?
seems GetAllNetworkInterfaces
cannot get all adapters :(
Unfortunately I lack the network gear for testing LAGG stuff.
Here is the function which I collect this information using ansible
$result = @{
changed = $false
ansible_facts = @{
ethtool = @{}
serverinfo = @{}
}
}
Function win2012andmore {
try {
$eths = Get-NetAdapter -physical | Select-Object name, MacAddress, Status, Speed
} catch {
Fail-Json -obj $result -message "Failed to search the network on the target: $($_.Exception.Message)"
}
foreach($eth in $eths){
$eth_info = @{}
$eth_info.mac = $eth.MacAddress.ToLower() -replace "-",":"
$eth_info.type = "physical"
if($eth.Status -eq "Up"){
$eth_info.link_detected = "yes"
}else{
$eth_info.link_detected = "no"
}
$eth_info.ip = @()
$IPS = ''
try{
$IPS = Get-NetIPAddress -InterfaceAlias $eth.Name | Where-Object {$_.AddressFamily -eq "ipv4" } | Select-Object IPAddress, PrefixLength
}catch{
}
foreach( $IP in $IPS) {
try{
$eth_info.ip += $IP.IPAddress + "/" + $IP.PrefixLength
}catch{
}
}
if($eth.Speed -eq 10000000000){
$eth_info.dev_type = "SFP+ (10GE)"
}elseif($eth.Speed -eq 10000000){
$eth_info.dev_type = "1000BASE-T (1GE)"
}else{
$eth_info.dev_type = "Other"
}
$result.ansible_facts.ethtool.Add($eth.Name, $eth_info)
}
# Search network team
try {
$netteams = Get-NetLbfoTeam | Select-Object Name, Members, Status
} catch {
Fail-Json -obj $result -message "Failed to search the network team on the target: $($_.Exception.Message)"
}
foreach ($netteam in $netteams) {
$team_info = @{}
$team_info.slave = @()
foreach( $eth in $netteam.Members ){
$team_info.slave += $eth
$result.ansible_facts.ethtool[$eth].Add("master", $netteam.Name)
}
if($netteam.Status -eq 0){
$team_info.link_detected = "yes"
}else{
$team_info.link_detected = "no"
}
$team_info.dev_type = "Link Aggregation Group (LAG)"
$team_info.type = "virtual"
$mac = Get-NetAdapter -Name $netteam.Name | Select-Object MacAddress
$team_info.mac = $mac.MacAddress.ToLower() -replace "-",":"
try{
$IPS = Get-NetIPAddress -InterfaceAlias $netteam.Name | Select-Object IPAddress, PrefixLength
}catch{
}
$team_info.ip = @()
foreach( $IP in $IPS) {
$team_info.ip += $IP.IPAddress + "/" + $IP.PrefixLength
}
$result.ansible_facts.ethtool.Add($netteam.Name, $team_info)
}
}
@raspi I have many machines with multiple NICs can test for you.
As I experiments, powershell Get-NetAdapter
can get all NICs and also WMI query do.
but C# GetAllNetworkInterfaces
not.
someone got the same issue too: https://stackoverflow.com/questions/25624472/getallnetworkinterfaces-return-an-incomplete-list
In C++, I used the GetIfTable2 function to get a list of all interfaces. And in C# you can use methods and classes from C++.
Submission type
Used version of operating system
In case of bug report: Is machine connected to Active Directory?
In case of bug report: Version the issue has been seen with
In case of bug report: Capture library used
In case of bug report: PowerShell information
PowerShell version used
What are your execution policies?
In case of bug report: Expected behaviour you didn't see
In case of bug report: Steps to reproduce the problem
Where is the problem:
*problem in the WinLLDPService/LLDPBase/Base.cs file line 66 The physical interfaces included in the LAG do not have NetworkInterfaceComponent.IPv components. Only the "Microsoft Network Adapter Multiplexor Protocol" is enabled, in addition to npcap**
In case of bug report: Additional details