码迷,mamicode.com
首页 > 其他好文 > 详细

Get IP Address for different Adpater

时间:2019-06-01 11:17:11      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:write   ddr   stat   spl   result   cmd   nta   config   etc   

 1 CLS
 2 $NetworkAdapters = Get-WmiObject -Class win32_networkadapter | ?{$_.PhysicalAdapter -eqTrue‘} |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 }

 

Get IP Address for different Adpater

标签:write   ddr   stat   spl   result   cmd   nta   config   etc   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!