我在powershell中有这种脚本
$NW = Get-WmiObject -Class Win32_NetworkAdapterConfiguration
$IP= " IPAddress: " + $NW.IPAddress
我如何只获得 IP 地址而不是旁边的垃圾?结果是此刻 IPaadress: xxxxxx fe80::9480:1f5c:9c1f:d03d
我在powershell中有这种脚本
$NW = Get-WmiObject -Class Win32_NetworkAdapterConfiguration
$IP= " IPAddress: " + $NW.IPAddress
我如何只获得 IP 地址而不是旁边的垃圾?结果是此刻 IPaadress: xxxxxx fe80::9480:1f5c:9c1f:d03d
$ipAddressV4List = (Get-WmiObject -Class Win32_NetworkAdapterConfiguration).Where{$_.IPAddress}.foreach{$_.IPAddress[0]}
$ipAddressV4List
192.168.1.7
10.235.3.220
(Get-NetIPAddress | Where-Object {$_.AddressFamily -eq 'IPv4'}).IPAddress
(Get-CimInstance -Class Win32_NetworkAdapterConfiguration).Where{$_.IPAddress}.foreach{$_.IPAddress[0]}