Get IP Address for different Adpater

 1 CLS
 2 $NetworkAdapters = Get-WmiObject -Class win32_networkadapter | ?{$_.PhysicalAdapter -eq ‘True‘} |select NetConnectionID
 3 foreach($NetworkAdapter in $NetworkAdapters)
 4 {
 5  $CurrentAdapter = ($NetworkAdapter |select  NetConnectionID).NetConnectionID
 6  $Result = CMD /C netsh interface ip show config name=$CurrentAdapter
 7  $IPInfos = ($Result|out-string)-split ([Environment]::NewLine)
 8  $DisconnectStatus = $true
 9  foreach($IPInfo in $IPInfos)
10  {
11
12     if($IPInfo -like ‘*IP Address*‘)
13     {
14       $DisconnectStatus = $false
15       $CurrentIPv4 = $IPInfo
16       $DeviceIP = ($CurrentIPv4 -replace(‘IP Address:‘,‘‘)).Trim()
17       #$DeviceIP
18       Write-Host "Device: $CurrentAdapter /IP Address: $DeviceIP" -ForegroundColor Blue
19     }
20  }
21  if($DisconnectStatus)
22  {
23    Write-Host "Device: $CurrentAdapter /Status: Disconnected " -ForegroundColor Blue
24  }
25 }

原文地址:https://www.cnblogs.com/kivin/p/10958850.html

时间: 2024-10-07 05:06:44

Get IP Address for different Adpater的相关文章

在windows下运行docker的问题【Error getting IP address: ***】

环境配置系统:windows 10docker:Docker Toolbox https://www.docker.com/products/docker-toolbox 问题描述windows下安装完Docker Toolbox后运行Docker Quickstart Terminal可能会看到如下错误 Creating Machine default... Running pre-create checks... Creating machine... Error creating mach

Java Regex match IP address

Reference: [1] https://www.mkyong.com/regular-expressions/how-to-validate-ip-address-with-regular-expression/ import java.util.regex.Matcher; import java.util.regex.Pattern; public class IPAddressValidator{ private Pattern pattern; private Matcher ma

router 分配ip address(dhcp)和dhcp中继

路由器的主要功能是网络寻址,有时候也需要用来分配ip地址.但用路由器分配地址又会加大路由器的负载,所以,有的时候我们可以把分配地址的工作交给一台PC. 1.使用router分配ip address: Router>en Router#conf t Enter configuration commands, one per line.  End with CNTL/Z. Router(config)#int vlan 1 Router(config-if)#ip dhcp pool vlan1  

poj2105 IP Address(简单题)

题目链接:http://poj.org/problem?id=2105 Description Suppose you are reading byte streams from any device, representing IP addresses. Your task is to convert a 32 characters long sequence of '1s' and '0s' (bits) to a dotted decimal format. A dotted decima

Debian static ip address

1 // /etc/network/interfaces 2 auto eth0 3 iface eth0 inet static 4 address <Your ip address> 5 netmask <Your netmask> 6 gateway <Your gateway address> 7 broadcast <Your broadcast address> 8 9 // /etc/resolv.conf 10 nameserver <

If application data needs to be sent to IP address xx.xx.xx.xx, how does it work in underneath network?

This is to illustrate the communication between two separate machines which don't have a direct physical connection. Application data is generated and passed to layer 3 (network layer) which wrapps up the data with the destination IP address. Then ha

Bringing up interface eth0: Determining if ip address 10.109.67.81 is already in use for device eth0...

重启网卡出现提示: Bringing up interface eth0:  Determining if ip address 10.109.67.81 is already in use for device eth0...                                                            [  OK  ] Bringing up interface eth1:  Determining if ip address 10.109.67.83

oracle 11g RAC安装节点二执行结果错误CRS-5005: IP Address: 192.168.1.24 is already in use in the network

[[email protected] ~]# /u01/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /u01/app/oraInventory to oins

Linux下network提示Determining if ip address

[[email protected] NetworkManager]# service network restart正在关闭接口 eth0: [确定]关闭环回接口: [确定]弹出环回接口: [确定]弹出界面 eth0: Determining if ip address 192.168.8.102 is already in use for device eth0... vi /etc/sysconfig/network-scripts/ifcfg-eth0 添加   ARPCHECK=no