0

我试过这个,

  Get-CimInstance Win32_NetworkAdapterConfiguration -ComputerName $computerName | Where-Object { $_.AddressFamily -eq 'IPv6' }

还有这个,

Get-NetIPAddress -ComputerName $computerName | Where-Object {$_.AddressFamily -eq 'IPV6'}

但似乎没有什么对我有用 Get-CimInstance 正确获取 IPV6 地址。我只是得到与参数相关的错误。

4

3 回答 3

0

好的,这是一个使用 Get-CimInstance 的可行解决方案。

$x = (Get-CimInstance Win32_NetworkAdapterConfiguration -ComputerName "DellXPS8700").IPAddress
For ( $Cntr = 0 ; $Cntr -lt $x.Count; $cntr++) {
   If ($Null -ne $x[$($Cntr)] ) {
     If ($x[$($Cntr)].IndexOf(":") -ne -1) {
       "$($x[$($Cntr)])"
     }
   }
}

输出:

fe80::59be:16e2:a647:9c73
2606:a000:1321:425e:2413:c2f5:cb57:6252
2606:a000:1321:425e:59be:16e2:a647:9c73

高温高压

于 2020-06-11T22:10:40.280 回答
0

您的第一个示例,该 CIMInstance 不包含名为AddressFamily.

您的第二个示例是一个完全有效的命令。

Get-NetIPAddress -ComputerName $computerName | Where-Object {$_.AddressFamily -eq 'IPV6'}

您确定您computerName的不是空白或无法访问 (perms/network/psremote) 吗?

于 2020-06-11T01:43:58.793 回答
0
Invoke-Command -ComputerName "DellXPS8700" -ScriptBlock {
(Get-NetIPAddress  | Where-Object {$_.AddressFamily -eq 'IPV6'}) |
 Select-Object InterfaceAlias, IPAddress | FT }

样本输出:

InterfaceAlias                 IPAddress                              
--------------                 ---------                              
Loopback Pseudo-Interface 1    ::1                                    
Ethernet                       fe80::59be:16e2:a647:9c73%10           
Ethernet                       2606:a000:1321:425e:59be:16e2:a647:9c73
Ethernet                       2606:a000:1321:425e:2413:c2f5:cb57:6252
Bluetooth Network Connection 2 fe80::9037:3e88:9c22:8ce2%3            

我认为地址在不引用适配器的情况下没有多大帮助。

当然,您可以将其置于循环中以获取整套机器的值。

高温高压

于 2020-06-11T21:00:03.747 回答