我正在尝试获取IP地址和mac地址。下面的代码工作正常但不适用于Windows R2,任何人都有任何建议吗?
小学Ip
(get-WmiObject Win32_NetworkAdapterConfiguration|Where {$_.Ipaddress.length -gt 1}).IPAddress | Select-object -index 0
主要MAC:
(Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.ipenabled -EQ $true}).Macaddress | select-object -first 1
答案 0 :(得分:1)
多年来我没有W2K8R2服务器,但是这样试试......
Get-WmiObject win32_networkadapterconfiguration `
| Select-Object -Property @{name='IPAddress';Expression={($_.IPAddress[0])}},MacAddress `
| Where IPAddress -NE $null
IPAddress MacAddress
--------- ----------
10.0.0.11 50:7B:9D:96:5C:51