{"id":2247,"date":"2014-01-12T00:01:00","date_gmt":"2014-01-12T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2014\/01\/12\/weekend-scripter-use-powershell-to-identify-network-adapter-characteristics\/"},"modified":"2014-01-12T00:01:00","modified_gmt":"2014-01-12T00:01:00","slug":"weekend-scripter-use-powershell-to-identify-network-adapter-characteristics","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-use-powershell-to-identify-network-adapter-characteristics\/","title":{"rendered":"Weekend Scripter: Use PowerShell to Identify Network Adapter Characteristics"},"content":{"rendered":"<p><b>Summary<\/b>: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to identify network adapter characteristics.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Today I am kicking off Network Adapter Week.<\/p>\n<p style=\"margin-left:30px\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3757.Sat007.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3757.Sat007.png\" alt=\"Image of logo\" title=\"Image of logo\" \/><\/a><\/p>\n<p style=\"margin-left:30px\"><b>Note<\/b>&nbsp; <a href=\"http:\/\/powershellsaturday.com\/007\/conference\/powershell-saturday-007-charlotte-nc-february-8-2014\/\" target=\"_blank\">PowerShell Saturday #007<\/a> will be held in Charlotte, North Carolina on February 8, 2014. This will be an awesome chance to meet and to learn from some of the best PowerShellers around. In fact, five of the speakers are also speakers at the PowerShell Summit this year. There are a limited number of tickets still available for this event, so you&rsquo;ll want to sign up now. The Scripting Wife wrote a great post that provides a quick overview of the event: <a href=\"https:\/\/devblogs.microsoft.com\/scripting\/psst-charlotte-powershell-saturday-details-leaked\/\" target=\"_blank\">Psst&#8230;Charlotte PowerShell Saturday Details Leaked<\/a>.<\/p>\n<p>One of the great things about Windows Management Instrumentation (WMI) is the way that it can provide detailed information. The bad thing is that it requires a specialist level of knowledge and understanding to effectively use it and to understand the information. (Either that or a good search engine, such as&nbsp;<a href=\"http:\/\/www.bing.com\/\" target=\"_blank\">BING<\/a>, and an awesome repository of information, such as the&nbsp;<a href=\"http:\/\/technet.microsoft.com\/en-us\/scriptcenter\" target=\"_blank\">Script Center<\/a>.)<\/p>\n<h2>Using raw WMI to identify network adapters<\/h2>\n<p>One of the cool things about Windows PowerShell, since version 1.0, is that it provides easier access to WMI information. The bad thing, of course, is that it is still wrestling with WMI, which some IT pros seem to hate (or at least dislike). The great thing about using raw WMI is that it provides compatibility with older versions of the operating system. For example, using raw WMI and Windows PowerShell would make it possible to talk to Windows XP, Windows 2003 Server, Windows 2008 Server, Windows Vista, Windows Server 2008&nbsp;R2, and Windows 7, in addition to the modern operating systems of Windows 8.1, Windows&nbsp;8, Windows Server&nbsp;2012&nbsp;R2, and Windows Server&nbsp;2012.<\/p>\n<p>So how do I do it? I used to be able to find our real network card by finding the one that was bound to TCP\/IP. I would query the Win32_NetworkAdapterConfiguration WMI class, and filter on the <b>IPEnabled<\/b> property. Using this approach, I would have done something like this:<\/p>\n<p style=\"margin-left:30px\">Get-WmiObject -Class Win32_NetworkAdapterConfiguration&nbsp; -filter &quot;IPEnabled = $true&quot;<\/p>\n<p>The problem with this methodology these days is that some of the pseudo adapters are also IP enabled. The previous command would eliminate many, but not necessarily all, of the adapters.<\/p>\n<p>A better approach is to look at the Win32_NetworkAdapter class and query the <b>NetConnectionStatus<\/b> property. By using this technique, I return only network adapter devices that are actually connected to a network. Although it is possible that a pseudo adapter could sneak in under the wire, the likelihood is more remote. In this command, I will use the <b>Get-WmiObject<\/b> Windows PowerShell cmdlet to return all instances of Win32_NetworkAdapter class on the computer. I then create a table to display the data returned by the <b>NetConnectionStatus<\/b> property.<\/p>\n<p style=\"margin-left:30px\">Get-WmiObject -Class Win32_NetworkAdapter |<\/p>\n<p style=\"margin-left:30px\">Format-Table -Property Name, NetConnectionStatus &ndash;AutoSize<\/p>\n<p>The fruit of our labor is somewhat impressive. I have a nice table that details all of the fake and real network adapters on our laptop, and the connection status of each. Here is the list from my laptop:<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NetConnectionStatus<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p style=\"margin-left:30px\">WAN Miniport (L2TP)<\/p>\n<p style=\"margin-left:30px\">WAN Miniport (PPTP)<\/p>\n<p style=\"margin-left:30px\">WAN Miniport (PPPOE)<\/p>\n<p style=\"margin-left:30px\">WAN Miniport (IPv6)<\/p>\n<p style=\"margin-left:30px\">Intel(R) PRO\/1000 PL Network Connection&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2<\/p>\n<p style=\"margin-left:30px\">Intel(R) PRO\/Wireless 3945ABG Network Connection 0<\/p>\n<p style=\"margin-left:30px\">WAN Miniport (IP)<\/p>\n<p style=\"margin-left:30px\">Microsoft 6to4 Adapter<\/p>\n<p style=\"margin-left:30px\">Bluetooth Personal Area Network<\/p>\n<p style=\"margin-left:30px\">RAS Async Adapter<\/p>\n<p style=\"margin-left:30px\">isatap.{51AAF9FF-857A-4460-9F17-92F7626DC420}<\/p>\n<p style=\"margin-left:30px\">Virtual Machine Network Services Driver<\/p>\n<p style=\"margin-left:30px\">Microsoft ISATAP Adapter<\/p>\n<p style=\"margin-left:30px\">Bluetooth Device (Personal Area Network)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7<\/p>\n<p style=\"margin-left:30px\">6TO4 Adapter<\/p>\n<p style=\"margin-left:30px\">Microsoft 6to4 Adapter<\/p>\n<p style=\"margin-left:30px\">Microsoft Windows Mobile Remote Adapter<\/p>\n<p style=\"margin-left:30px\">isatap.launchmodem.com<\/p>\n<p style=\"margin-left:30px\">isatap.{647A0048-DF48-4E4D-B07B-2AE0995B269F}<\/p>\n<p style=\"margin-left:30px\">Microsoft Windows Mobile Remote Adapter<\/p>\n<p style=\"margin-left:30px\">WAN Miniport (SSTP)<\/p>\n<p style=\"margin-left:30px\">WAN Miniport (Network Monitor)<\/p>\n<p style=\"margin-left:30px\">6TO4 Adapter<\/p>\n<p style=\"margin-left:30px\">6TO4 Adapter<\/p>\n<p style=\"margin-left:30px\">Microsoft 6to4 Adapter<\/p>\n<p style=\"margin-left:30px\">Microsoft Windows Mobile Remote Adapter<\/p>\n<p style=\"margin-left:30px\">isatap.{C210F3A1-6EAC-4308-9311-69EADBA00A04}<\/p>\n<p style=\"margin-left:30px\">isatap.launchmodem.com<\/p>\n<p style=\"margin-left:30px\">Virtual Machine Network Services Driver<\/p>\n<p style=\"margin-left:30px\">Virtual Machine Network Services Driver<\/p>\n<p style=\"margin-left:30px\">Teredo Tunneling Pseudo-Interface<\/p>\n<p style=\"margin-left:30px\">isatap.{647A0048-DF48-4E4D-B07B-2AE0995B269F}<\/p>\n<p>There are two things you will no doubt notice. The first is that most of the network adapters report no status what-so-ever. The second thing you will notice is that the ones that do report a status do so in some kind of code. The previous table is therefore pretty much useless! But it does look nice.<\/p>\n<p>A little work in the Windows SDK looking up the Win32_NetworkAdapter WMI class, and I run across the following information:<\/p>\n<p style=\"margin-left:30px\">Value&nbsp;&nbsp;&nbsp; Meaning<\/p>\n<p style=\"margin-left:30px\">0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Disconnected<\/p>\n<p style=\"margin-left:30px\">1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Connecting<\/p>\n<p style=\"margin-left:30px\">2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Connected<\/p>\n<p style=\"margin-left:30px\">3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Disconnecting<\/p>\n<p style=\"margin-left:30px\">4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hardware not present<\/p>\n<p style=\"margin-left:30px\">5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hardware disabled<\/p>\n<p style=\"margin-left:30px\">6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hardware malfunction<\/p>\n<p style=\"margin-left:30px\">7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Media disconnected<\/p>\n<p style=\"margin-left:30px\">8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Authenticating<\/p>\n<p style=\"margin-left:30px\">9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Authentication succeeded<\/p>\n<p style=\"margin-left:30px\">10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Authentication failed<\/p>\n<p style=\"margin-left:30px\">11&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Invalid address<\/p>\n<p style=\"margin-left:30px\">12&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Credentials required<\/p>\n<p>The value of 2 means the network adapter is connected. Here is the command I wrote to exploit the results of our research.<\/p>\n<p style=\"margin-left:30px\">Get-WmiObject -class win32_networkadapter -filter &quot;NetConnectionStatus = 2&quot; |<\/p>\n<p style=\"margin-left:30px\">format-list -Property [a-z]*<\/p>\n<p>Such ecstasy is short lived, however, when I realize that although I have indeed returned information about a network adapter that is connected, I do not have any of the configuration information from the card.<\/p>\n<p>What I need is to be able to use the <b>NetConnectionStatus<\/b> property from Win32_NetworkAdapter and to obtain the TCP\/IP configuration information from the Win32_NetworkAdapterConfiguration WMI class. This sounds like a job for an association class.<\/p>\n<p>In VBScript, querying an association class involved performing confusing AssociatorsOf queries. (Refer to the MSPress book, <a href=\"http:\/\/www.amazon.com\/Microsoft%C2%AE-Windows%C2%AE-Scripting-WMI-Self-Paced\/dp\/0735622310\/ref=sr_1_1?ie=UTF8&amp;qid=1389289441&amp;sr=8-1&amp;keywords=ed+wilson+wmi\" target=\"_blank\">Window Scripting with WMI: Self Paced Learning Guide<\/a> for more information about this technique.)<\/p>\n<p>By using the association class with Windows PowerShell, I come up with the FilterAssociatedNetworkAdapters.ps1 script shown here:<\/p>\n<p style=\"margin-left:30px\">FilterAssociatedNetworkAdapters.ps1<\/p>\n<p style=\"margin-left:30px\">Param($computer = &quot;localhost&quot;)<\/p>\n<p style=\"margin-left:30px\">function funline ($strIN)<\/p>\n<p style=\"margin-left:30px\">{<\/p>\n<p style=\"margin-left:30px\">&nbsp;$num = $strIN.length<\/p>\n<p style=\"margin-left:30px\">&nbsp;for($i=1 ; $i -le $num ; $i++)<\/p>\n<p style=\"margin-left:30px\">&nbsp; { $funline = $funline + &quot;=&quot; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; Write-Host -ForegroundColor yellow $strIN<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; Write-Host -ForegroundColor darkYellow $funline<\/p>\n<p style=\"margin-left:30px\">} #end funline<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">Write-Host -ForegroundColor cyan &quot;Network adapter settings on $computer&quot;<\/p>\n<p style=\"margin-left:30px\">Get-WmiObject -Class win32_NetworkAdapterSetting `<\/p>\n<p style=\"margin-left:30px\">-computername $computer |<\/p>\n<p style=\"margin-left:30px\">Foreach-object `<\/p>\n<p style=\"margin-left:30px\">&nbsp;{<\/p>\n<p style=\"margin-left:30px\">&nbsp; If( ([wmi]$_.element).netconnectionstatus -eq 2)<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp; funline(&quot;Adapter: $($_.setting)&quot;)<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp; [wmi]$_.setting<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp; [wmi]$_.element<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; } #end if<\/p>\n<p style=\"margin-left:30px\">&nbsp;} #end foreach<\/p>\n<p>I begin the script by using a command-line parameter to allow us to run the script remotely, if needed. I use the <b>Param<\/b> statement to do this. I also create a function named <b>funline<\/b> that is used to underline the results of the query. It makes the output nicer if there is a large amount of data returned.<\/p>\n<p style=\"margin-left:30px\">Param($computer = &quot;localhost&quot;)<\/p>\n<p style=\"margin-left:30px\">function funline ($strIN)<\/p>\n<p style=\"margin-left:30px\">{<\/p>\n<p style=\"margin-left:30px\">&nbsp;$num = $strIN.length<\/p>\n<p style=\"margin-left:30px\">&nbsp;for($i=1 ; $i -le $num ; $i++)<\/p>\n<p style=\"margin-left:30px\">&nbsp; { $funline = $funline + &quot;=&quot; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; Write-Host -ForegroundColor yellow $strIN<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; Write-Host -ForegroundColor darkYellow $funline<\/p>\n<p style=\"margin-left:30px\">} #end funline<\/p>\n<p>I print out the name of the computer by using the <b>Write-Host<\/b> cmdlet as shown here. I use the color cyan so the text will show up nicely on the screen&hellip;unless of course your background is also cyan. Then the output will be written in invisible ink. That might also be cool.<\/p>\n<p style=\"margin-left:30px\">Write-Host -ForegroundColor cyan &quot;Network adapter settings on $computer&quot;<\/p>\n<p>Then I get down to actual WMI query. To do this, I use the <b>Get-WmiObject<\/b> cmdlet. I use the <b>&ndash;computername <\/b>parameter to allow the script to run against other computers, and I pipe the results to the <b>ForEach-Object<\/b> cmdlet.<\/p>\n<p style=\"margin-left:30px\">Get-WmiObject -Class win32_NetworkAdapterSetting `<\/p>\n<p style=\"margin-left:30px\">-computername $computer |<\/p>\n<p style=\"margin-left:30px\">Foreach-object `<\/p>\n<p>I need a way to look at the <b>netConnectionStatus<\/b> property of the Win32_NetworkAdapter class. This class is referred to by the reference returned from the association query. It is called element. To gain access to this class, I use the reference that was returned and feed it to the [WMI] type accelerator (it likes to receive a path, and this is what the reference is).<\/p>\n<p>Because the reference refers to a specific instance of a WMI class, and because the [WMI] type accelerator can query a specific instance of a class, I am now able to obtain the value of the <b>netConnectionStatus<\/b> property. So I say in our script, if it is equal to 2, I will print the name of the network adapter, the configuration that is held in the setting property, and the adapter information that is held in the element property. This section of the script is shown here:<\/p>\n<p style=\"margin-left:30px\">{<\/p>\n<p style=\"margin-left:30px\">&nbsp; If( ([wmi]$_.element).netconnectionstatus -eq 2)<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp; funline(&quot;Adapter: $($_.setting)&quot;)<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp; [wmi]$_.setting<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp; [wmi]$_.element<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; } #end if<\/p>\n<p>The result of running the script is that it displays information from the Win32_NetworkAdapter WMI class and information from the Win32_NetworkAdapterConfiguration class. It also shows us that I only have one connected network adapter:<\/p>\n<h2>Using NetSh<\/h2>\n<p>Microsoft created <b>NetSh<\/b> in 2000, and it has been a staple of networking ever since. When I open it these days, it displays a message that says it might be removed in future versions of Windows, and therefore, I should begin using Windows PowerShell. Here is the message:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-01.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-01.png\" alt=\"Image of message\" title=\"Image of message\" \/><\/a><\/p>\n<p>Now, because <b>NetSh<\/b> is an old style menu type application, it is possible to enter <b>NetSh<\/b>, and walk my way down through the menus until I arrive at the proper location. Along the way, if I get lost, I can use the <b>?<\/b> to obtain Help.<\/p>\n<p>The problem is that the Help is quite often not very helpful; therefore, at times it takes me nearly a dozen times before the command is correct. The great thing is that, for the most part, when I figure out a command, I can actually keep track of my location in the program, back out all the way, and enter the command as a one-liner. Here is the <b>NetSh<\/b> command to display network interface information that is bound to IPV4:<\/p>\n<p style=\"margin-left:30px\">netsh interface ipv4 show interfaces<\/p>\n<p>The output is shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-02.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-02.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<h3>Using PowerShell in later versions<\/h3>\n<p>If I have the advantage of Windows 8.1, Windows 8.1, Windows Server 2012R2, or Windows Server 2012, I have the built-in <b>NetAdapter<\/b> module. Due to the way that modules autoload in Windows Powell, I do not need to remember that I am using functions that exist in the <b>NetAdapter<\/b> module. I can use Windows PowerShell&nbsp;4.0 or Windows PowerShell&nbsp;3.0, and the behavior will be the same. (Windows&nbsp;8.1 and Windows Server&nbsp;2012&nbsp;R2 come with Windows PowerShell&nbsp;4.0 and Windows&nbsp;8 and Windows Server&nbsp;2012 come with Windows PowerShell&nbsp;3.0.)<\/p>\n<p>The <b>Get-NetAdapter<\/b> cmdlet returns the name, interface description, index number, and status of all network adapters present on the system. This is the default display of information, and it is shown in the following image:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-03.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-03.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>To focus in on a particular network adapter, I use the <b>Name<\/b><i> <\/i>parameter, and I supply the name of the network adapter. The good thing is that in Windows&nbsp;8 and Windows Server&nbsp;2012, the network connections receive new names. No more of the &ldquo;local area connection&rdquo; and &ldquo;local area connection(2)&rdquo; to attempt to demystify. The wired network adapter is simply <b>Ethernet<\/b><i> <\/i>and the wireless network adapter is <b>Wi-Fi<\/b><i>. <\/i>The following command retrieves only then <b>Ethernet<\/b><i> <\/i>network adapter:<\/p>\n<p style=\"margin-left:30px\">Get-NetAdapter -Name Ethernet<\/p>\n<p>To dive into the details of the Ethernet<i> <\/i>network adapter, I pipe the returned object to the <b>Format-List<\/b> cmdlet, and I choose all of the properties. (The following command uses the <b>fl <\/b>alias for the <b>Format-List<\/b> cmdlet.)<\/p>\n<p style=\"margin-left:30px\">Get-NetAdapter -Name ethernet | fl *<\/p>\n<p>The command and output associated with the command are shown in the image that follows.&nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-04.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-04.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>There are a number of excellent properties that might bear further investigation. For example, there are the <b>AdminStatus<\/b><i> <\/i>and the <b>MediaConnectionStatus<\/b><i> <\/i>properties. The following command returns these properties:<\/p>\n<p style=\"margin-left:30px\">Get-NetAdapter -Name ethernet | select adminstatus, MediaConnectionState<\/p>\n<p>Of course, there are also other properties that might be interesting. These properties are shown here, along with their associated output (this is a single logical command broken on two lines):<\/p>\n<p style=\"margin-left:30px\">Get-NetAdapter -Name ethernet |<\/p>\n<p style=\"margin-left:30px\">select ifname, adminstatus, MediaConnectionState, LinkSpeed, PhysicalMediaType<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">ifName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Ethernet_7<\/p>\n<p style=\"margin-left:30px\">AdminStatus&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Down<\/p>\n<p style=\"margin-left:30px\">MediaConnectionState : Unknown<\/p>\n<p style=\"margin-left:30px\">LinkSpeed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 0 bps<\/p>\n<p style=\"margin-left:30px\">PhysicalMediaType&nbsp;&nbsp;&nbsp; : 802.3<\/p>\n<p>I decide to look only for network adapters that are in the admin status of <b>Up<\/b>:<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Get-NetAdapter | where adminstatus -eq &quot;up&quot;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InterfaceDescription&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ifIndex Status<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;- &#8212;&#8212;<\/p>\n<p style=\"margin-left:30px\">vEthernet (InternalSwi&#8230; Hyper-V Virtual Ethernet Adapter #3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 22 Up<\/p>\n<p style=\"margin-left:30px\">vEthernet (ExternalSwi&#8230; Hyper-V Virtual Ethernet Adapter #2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 19 Up<\/p>\n<p style=\"margin-left:30px\">Bluetooth Network Conn&#8230; Bluetooth Device (Personal Area Netw&#8230;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 15 Disconn&#8230;<\/p>\n<p style=\"margin-left:30px\">Wi-Fi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Intel(R) Centrino(R) Ultimate-N 6300&#8230;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12 Up<\/p>\n<p>To find the disabled network adapters, I change <b>AdminStatus<\/b><i> <\/i>from <b>Up<\/b><i> <\/i>to <b>Down<\/b>, as shown here:<\/p>\n<p style=\"margin-left:30px\">Get-NetAdapter | where adminstatus -eq &quot;down&quot;<\/p>\n<p>I go back to my previous command, and modify it to return <b>Wi-Fi<\/b> information. This command and associated output are shown here (this is a single logical command):<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Get-NetAdapter -Name wi-fi |<\/p>\n<p style=\"margin-left:30px\">select ifname, adminstatus, MediaConnectionState, LinkSpeed, PhysicalMediaType<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">ifName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : WiFi_0<\/p>\n<p style=\"margin-left:30px\">AdminStatus&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Up<\/p>\n<p style=\"margin-left:30px\">MediaConnectionState : Connected<\/p>\n<p style=\"margin-left:30px\">LinkSpeed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 54 Mbps<\/p>\n<p style=\"margin-left:30px\">PhysicalMediaType&nbsp;&nbsp;&nbsp; : Native 802.11<\/p>\n<p>If I want to find any network adapters sniffing the network, I look for <b>PromiscousMode<\/b><i>. <\/i>This command is shown here:<\/p>\n<p style=\"margin-left:30px\">Get-NetAdapter | ? PromiscuousMode -eq $true<\/p>\n<p>When I combine the <b>Get-NetAdapter<\/b> function with the <b>Get-NetAdapterBinding<\/b> function, I can easily find out which protocols are bound to which network adapter. As shown in the following command, I send the results to <b>Where-Object<\/b> and check to see if the enabled property is equal to True:<\/p>\n<p style=\"margin-left:30px\">Get-NetAdapter | Get-NetAdapterBinding | ? enabled -eq $true<\/p>\n<p>Here is an example of the command and the output from the command:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-05.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-05.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>If I want to find which network adapters have the Client for Microsoft Networks bound, I need to first see which protocols are enabled (using the syntax from the previous command), and I need to see which one of the enabled protocols have the display name of Client for Microsoft Networks. This requires a compound <b>Where-Object<\/b> statement. Therefore, I cannot use the simplified syntax. Also, because only one of the protocols begins with <b>Client<\/b>, I can use that to shorten my query just a bit. Here is the command I use (this is a one-line command that I broke at the pipe character to make a better display):<\/p>\n<p style=\"margin-left:30px\">Get-NetAdapter |<\/p>\n<p style=\"margin-left:30px\">Get-NetAdapterBinding |<\/p>\n<p style=\"margin-left:30px\">where {$_.enabled -AND $_.displayname -match &#039;client&#039;}<\/p>\n<p>The command and associated output are shown in the following image:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-06.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-12-14-06.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>Join me tomorrow when I will continue Network Adapter Week by talking about enabling and disabling network adapters.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to identify network adapter characteristics. Microsoft Scripting Guy, Ed Wilson, is here. Today I am kicking off Network Adapter Week. Note&nbsp; PowerShell Saturday #007 will be held in Charlotte, North Carolina on February 8, 2014. This will be an awesome chance to meet and [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[36,34,332,37,3,61,45],"class_list":["post-2247","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-client-side-management","tag-hardware","tag-network-adapters","tag-networking","tag-scripting-guy","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to identify network adapter characteristics. Microsoft Scripting Guy, Ed Wilson, is here. Today I am kicking off Network Adapter Week. Note&nbsp; PowerShell Saturday #007 will be held in Charlotte, North Carolina on February 8, 2014. This will be an awesome chance to meet and [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=2247"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2247\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=2247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}