$NetConf = Get-NetIPConfiguration
$Adapters = Get-NetAdapter -Physical
$NetAdapterStatus = $Adapters | ForEach-Object {
$Adapter = $PSItem
$AdapterProfiles = $NetConf | where {$Adapter.ifIndex -eq $_.InterfaceIndex}
$AdapterProfiles | Select-Object
@{n='Name';e={$Adapter.Name}},
@{n='Status';e={$Adapter.Status}},
@{n='MAC';e={$Adapter.LinkLayerAddress}},
@{n='IP';e={$Adapter.IPAddress}}
}
Write-Host $NetAdapterStatus
我有结果:名称、状态、MAC 等 IPv4Address=Microsoft.Management.Infrastructure.CimInstance[] 为什么?
你可以这样说来获取信息。
或者通过您选择使用这种方式的 cmdlts: