Burada anlatılan SordumNET Makalesi :
Tüm ağ bağdaştırıcı bilgilerini komutla bulun
https://www.sordum.net/73393/tum-ag-bag ... tla-bulun/ isimli makale de geçen PS komutlarının toplu versiyon betikleri aşağıdadır.
01_All_Network_Adapters.ps1
Kod: Tümünü seç
# ==============================================================================
# Script : 01_All_Network_Adapters.ps1
# Purpose : List all network adapters with basic information
# Compat : Windows PowerShell 5.1 / PowerShell 7.x
# ==============================================================================
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
function Get-AllAdapters {
Write-Host ""
Write-Host "========================================================" -ForegroundColor Cyan
Write-Host " ALL NETWORK ADAPTERS - FULL LIST " -ForegroundColor Cyan
Write-Host "========================================================" -ForegroundColor Cyan
Write-Host ""
$adapters = Get-NetAdapter -IncludeHidden | Sort-Object InterfaceIndex
if (-not $adapters) {
Write-Host "[WARNING] No network adapters found." -ForegroundColor Yellow
return
}
$counter = 0
foreach ($adapter in $adapters) {
$counter++
$statusColor = if ($adapter.Status -eq "Up") { "Green" } `
elseif ($adapter.Status -eq "Disabled") { "DarkGray" } `
else { "Yellow" }
Write-Host "--- Adapter #$counter ---" -ForegroundColor White
Write-Host (" Name : {0}" -f $adapter.Name)
Write-Host (" Description : {0}" -f $adapter.InterfaceDescription)
Write-Host (" Interface Idx : {0}" -f $adapter.InterfaceIndex)
Write-Host (" Status : {0}" -f $adapter.Status) -ForegroundColor $statusColor
Write-Host (" MAC Address : {0}" -f $adapter.MacAddress)
Write-Host (" Media Type : {0}" -f $adapter.MediaType)
Write-Host (" Link Speed : {0}" -f $adapter.LinkSpeed)
Write-Host (" Connector : {0}" -f $adapter.ConnectorPresent)
Write-Host ""
}
Write-Host "--------------------------------------------------------" -ForegroundColor DarkGray
Write-Host (" Total adapters found: {0}" -f $counter) -ForegroundColor Cyan
Write-Host "========================================================" -ForegroundColor Cyan
Write-Host ""
}
Get-AllAdapters
Read-Host "`nPress ENTER to exit."
Kod: Tümünü seç
# ==============================================================================
# Script : 02_Detailed_Adapter_Info.ps1
# Purpose : Comprehensive info for all adapters: MAC, speed, IP, DNS, gateway
# Compat : Windows PowerShell 5.1 / PowerShell 7.x
# Fix : Replaced Get-NetIPConfiguration with direct cmdlets to suppress
# CimJobException errors on hidden/tunnel/WAN-miniport interfaces
# ==============================================================================
Set-StrictMode -Version Latest
$ErrorActionPreference = "SilentlyContinue"
function Format-Speed {
param ([long]$SpeedBps)
if ($SpeedBps -ge 1000000000) { return "{0} Gbps" -f ($SpeedBps / 1000000000) }
elseif ($SpeedBps -ge 1000000) { return "{0} Mbps" -f ($SpeedBps / 1000000) }
elseif ($SpeedBps -gt 0) { return "{0} Kbps" -f ($SpeedBps / 1000) }
else { return "N/A" }
}
function Get-AdapterIPInfo {
param ([int]$IfIndex)
# --- IPv4 address ---
$ipv4obj = Get-NetIPAddress -InterfaceIndex $IfIndex -AddressFamily IPv4 `
-ErrorAction SilentlyContinue |
Where-Object { $_.IPAddress -notlike "169.254.*" } |
Select-Object -First 1
# Fall back to link-local only if nothing else exists
if (-not $ipv4obj) {
$ipv4obj = Get-NetIPAddress -InterfaceIndex $IfIndex -AddressFamily IPv4 `
-ErrorAction SilentlyContinue | Select-Object -First 1
}
$ipv4Str = if ($ipv4obj) { "{0}/{1}" -f $ipv4obj.IPAddress, $ipv4obj.PrefixLength } else { "N/A" }
# --- IPv6 address (global/link-local) ---
$ipv6obj = Get-NetIPAddress -InterfaceIndex $IfIndex -AddressFamily IPv6 `
-ErrorAction SilentlyContinue |
Where-Object { $_.PrefixOrigin -ne "WellKnown" } |
Select-Object -First 1
$ipv6Str = if ($ipv6obj) { "{0}/{1}" -f $ipv6obj.IPAddress, $ipv6obj.PrefixLength } else { "N/A" }
# --- Default gateway ---
$gwObj = Get-NetRoute -InterfaceIndex $IfIndex -DestinationPrefix "0.0.0.0/0" `
-ErrorAction SilentlyContinue | Select-Object -First 1
$gwStr = if ($gwObj -and $gwObj.NextHop -ne "0.0.0.0") { $gwObj.NextHop } else { "N/A" }
# --- DNS servers ---
$dnsObj = Get-DnsClientServerAddress -InterfaceIndex $IfIndex -AddressFamily IPv4 `
-ErrorAction SilentlyContinue
$dnsStr = if ($dnsObj -and $dnsObj.ServerAddresses) {
($dnsObj.ServerAddresses | Where-Object { $_ -ne "" }) -join ", "
} else { "N/A" }
if ($dnsStr -eq "") { $dnsStr = "N/A" }
# --- DHCP ---
$ipIf = Get-NetIPInterface -InterfaceIndex $IfIndex -AddressFamily IPv4 `
-ErrorAction SilentlyContinue
$dhcpStr = if ($ipIf) { if ($ipIf.Dhcp -eq "Enabled") { "Yes" } else { "No" } } else { "N/A" }
return [PSCustomObject]@{
IPv4 = $ipv4Str
IPv6 = $ipv6Str
Gateway = $gwStr
DNS = $dnsStr
DHCP = $dhcpStr
}
}
function Get-DetailedAdapterInfo {
Write-Host ""
Write-Host "=================================================================" -ForegroundColor Cyan
Write-Host " DETAILED NETWORK ADAPTER INFORMATION REPORT " -ForegroundColor Cyan
Write-Host "=================================================================" -ForegroundColor Cyan
Write-Host ""
$adapters = Get-NetAdapter -IncludeHidden | Sort-Object InterfaceIndex
foreach ($adapter in $adapters) {
$ifIndex = $adapter.InterfaceIndex
$ipInfo = Get-AdapterIPInfo -IfIndex $ifIndex
$speedFormatted = if ($adapter.ReceiveLinkSpeed -gt 0) {
Format-Speed -SpeedBps $adapter.ReceiveLinkSpeed
} else { "N/A" }
$cimAdapter = Get-CimInstance -ClassName Win32_NetworkAdapter `
-Filter "InterfaceIndex=$ifIndex" -ErrorAction SilentlyContinue
$lastReset = if ($cimAdapter -and $cimAdapter.TimeOfLastReset) {
$cimAdapter.TimeOfLastReset.ToString("yyyy-MM-dd HH:mm:ss")
} else { "N/A" }
$statusColor = switch ($adapter.Status) {
"Up" { "Green" }
"Disabled" { "DarkGray" }
default { "Yellow" }
}
Write-Host "-----------------------------------------------------------------" -ForegroundColor DarkGray
Write-Host (" [#{0}] {1}" -f $ifIndex, $adapter.Name) -ForegroundColor White
Write-Host "-----------------------------------------------------------------" -ForegroundColor DarkGray
Write-Host (" Description : {0}" -f $adapter.InterfaceDescription)
Write-Host (" Status : {0}" -f $adapter.Status) -ForegroundColor $statusColor
Write-Host (" MAC Address : {0}" -f $(if ($adapter.MacAddress) { $adapter.MacAddress } else { "N/A" })) -ForegroundColor Yellow
Write-Host (" Link Speed : {0}" -f $speedFormatted) -ForegroundColor Cyan
Write-Host (" Media Type : {0}" -f $adapter.MediaType)
Write-Host (" Physical Adapter : {0}" -f $adapter.ConnectorPresent)
Write-Host (" Admin Status : {0}" -f $adapter.AdminStatus)
Write-Host ""
Write-Host (" IPv4 Address : {0}" -f $ipInfo.IPv4)
Write-Host (" IPv6 Address : {0}" -f $ipInfo.IPv6)
Write-Host (" Default Gateway : {0}" -f $ipInfo.Gateway)
Write-Host (" DNS Servers : {0}" -f $ipInfo.DNS)
Write-Host (" DHCP Enabled : {0}" -f $ipInfo.DHCP)
Write-Host (" Last Reset : {0}" -f $lastReset)
Write-Host ""
}
Write-Host "=================================================================" -ForegroundColor Cyan
Write-Host (" Report generated : {0}" -f (Get-Date -Format "yyyy-MM-dd HH:mm:ss")) -ForegroundColor DarkGray
Write-Host "=================================================================" -ForegroundColor Cyan
Write-Host ""
}
Get-DetailedAdapterInfo
Read-Host "`nPress ENTER to exit."
Kod: Tümünü seç
# ==============================================================================
# Script : 03_Physical_Ethernet_Only.ps1
# Purpose : Show ONLY physical Ethernet adapters (no Wi-Fi, no virtual, no VPN)
# Compat : Windows PowerShell 5.1 / PowerShell 7.x
# ==============================================================================
Set-StrictMode -Version Latest
$ErrorActionPreference = "SilentlyContinue"
function Format-Speed {
param ([long]$SpeedBps)
if ($SpeedBps -ge 1000000000) { return "{0} Gbps" -f ($SpeedBps / 1000000000) }
elseif ($SpeedBps -ge 1000000) { return "{0} Mbps" -f ($SpeedBps / 1000000) }
elseif ($SpeedBps -gt 0) { return "{0} Kbps" -f ($SpeedBps / 1000) }
else { return "N/A" }
}
function Get-PhysicalEthernetAdapters {
Write-Host ""
Write-Host "=================================================================" -ForegroundColor Green
Write-Host " PHYSICAL ETHERNET ADAPTERS ONLY " -ForegroundColor Green
Write-Host " (Wi-Fi / Virtual / VPN / Loopback excluded) " -ForegroundColor DarkGreen
Write-Host "=================================================================" -ForegroundColor Green
Write-Host ""
# Filter: physical connector present + media type "802.3" (Ethernet standard)
# Exclude known virtual/tunnel patterns in description
$excludePatterns = @(
"Bluetooth", "Virtual", "Hyper-V", "vEthernet", "Loopback",
"Pseudo", "TAP", "VPN", "WAN Miniport", "Tunnel", "Teredo",
"ISATAP", "Wi-Fi", "Wireless", "802.11", "PPPoE"
)
$allAdapters = Get-NetAdapter -IncludeHidden | Where-Object {
$_.ConnectorPresent -eq $true -and
($_.MediaType -eq "802.3" -or $_.PhysicalMediaType -eq "802.3")
}
$ethernetAdapters = $allAdapters | Where-Object {
$desc = $_.InterfaceDescription
$name = $_.Name
$match = $false
foreach ($pattern in $excludePatterns) {
if ($desc -like "*$pattern*" -or $name -like "*$pattern*") {
$match = $true
break
}
}
-not $match
} | Sort-Object InterfaceIndex
if (-not $ethernetAdapters) {
Write-Host "[INFO] No physical Ethernet adapter found matching criteria." -ForegroundColor Yellow
Write-Host ""
Write-Host "Tip: If you have an Ethernet adapter, check its media type or" -ForegroundColor DarkGray
Write-Host " confirm the cable is connected and driver is installed." -ForegroundColor DarkGray
Write-Host ""
return
}
$counter = 0
foreach ($adapter in $ethernetAdapters) {
$counter++
$ifIndex = $adapter.InterfaceIndex
# IP configuration
$ipConfig = Get-NetIPConfiguration -InterfaceIndex $ifIndex -ErrorAction SilentlyContinue
$ipv4 = $ipConfig.IPv4Address | Where-Object { $_ } | Select-Object -First 1
$gateway = $ipConfig.IPv4DefaultGateway | Select-Object -First 1
$dnsRaw = $ipConfig.DNSServer | Where-Object { $_ } | Select-Object -ExpandProperty ServerAddresses -ErrorAction SilentlyContinue
$dnsStr = if ($dnsRaw) { ($dnsRaw -join ", ") } else { "N/A" }
# DHCP
$ipv4if = Get-NetIPInterface -InterfaceIndex $ifIndex -AddressFamily IPv4 -ErrorAction SilentlyContinue
$dhcpEnabled = if ($ipv4if) { if ($ipv4if.Dhcp -eq "Enabled") { "Yes" } else { "No" } } else { "N/A" }
# Speed
$speedStr = if ($adapter.ReceiveLinkSpeed -gt 0) {
Format-Speed -SpeedBps $adapter.ReceiveLinkSpeed
} else { "N/A" }
# Full duplex info
$cimAdapter = Get-CimInstance -ClassName Win32_NetworkAdapter `
-Filter "InterfaceIndex=$ifIndex" -ErrorAction SilentlyContinue
$fullDuplex = if ($cimAdapter -and $cimAdapter.FullDuplex -ne $null) {
if ($cimAdapter.FullDuplex) { "Full-Duplex" } else { "Half-Duplex" }
} else { "N/A" }
$adapterConfig = Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration `
-Filter "InterfaceIndex=$ifIndex" -ErrorAction SilentlyContinue
$dhcpServer = if ($adapterConfig -and $adapterConfig.DHCPServer) {
$adapterConfig.DHCPServer
} else { "N/A" }
$statusColor = switch ($adapter.Status) {
"Up" { "Green" }
"Disabled" { "DarkGray" }
default { "Yellow" }
}
Write-Host "-----------------------------------------------------------------" -ForegroundColor DarkGray
Write-Host (" [Ethernet #{0}] {1}" -f $counter, $adapter.Name) -ForegroundColor White
Write-Host "-----------------------------------------------------------------" -ForegroundColor DarkGray
Write-Host (" Interface Index : {0}" -f $ifIndex)
Write-Host (" Description : {0}" -f $adapter.InterfaceDescription)
Write-Host (" Status : {0}" -f $adapter.Status) -ForegroundColor $statusColor
Write-Host ""
Write-Host (" MAC Address : {0}" -f $adapter.MacAddress) -ForegroundColor Yellow
Write-Host (" Link Speed : {0}" -f $speedStr) -ForegroundColor Cyan
Write-Host (" Duplex Mode : {0}" -f $fullDuplex)
Write-Host (" Media Type : {0}" -f $adapter.MediaType)
Write-Host (" Physical Type : {0}" -f $adapter.PhysicalMediaType)
Write-Host ""
Write-Host (" IPv4 Address : {0}" -f $(if ($ipv4) { "$($ipv4.IPAddress)/$($ipv4.PrefixLength)" } else { "N/A" }))
Write-Host (" Default Gateway : {0}" -f $(if ($gateway) { $gateway.NextHop } else { "N/A" }))
Write-Host (" DNS Servers : {0}" -f $dnsStr)
Write-Host (" DHCP Enabled : {0}" -f $dhcpEnabled)
Write-Host (" DHCP Server : {0}" -f $dhcpServer)
Write-Host ""
}
Write-Host "=================================================================" -ForegroundColor Green
Write-Host (" Physical Ethernet adapters found: {0}" -f $counter) -ForegroundColor Green
Write-Host (" Report generated : {0}" -f (Get-Date -Format "yyyy-MM-dd HH:mm:ss")) -ForegroundColor DarkGray
Write-Host "=================================================================" -ForegroundColor Green
Write-Host ""
}
Get-PhysicalEthernetAdapters
Read-Host "`nPress ENTER to exit."

