PowerShell provides a bunch of cmdlets through the NetAdapter module to manage network adapters. Through this article, we are going to discuss how we get the network adapter details, properties, etc, using PowerShell cmdlet(s).
Get-NetAdapter is to get the details/properties of the network adapter. The below command shows the basic details of the network adapter.
PS C:\> Get-NetAdapter Name InterfaceDescription ifIndex Status MacAddress LinkSpeed ---- -------------------- ------- ------ ---------- ---- Ethernet Realtek PCIe GbE Family Controller 9 Disconnected xx-xx-xx-xx-xx-xx ...s Wi-Fi Intel(R) Wireless-AC 9260 160MHz 6 Up xx-xx-xx-xx-xx-xx ...s
By default, this command will display only visible network adapters. To view all network adapters, including hidden ones, we need to pass
-IncldueHidden parameter. The below command displays all visible and hidden network adapters.
PS C:\> Get-Netadapter -IncludeHidden
-Physical parameter to the command, we can get all physical network adapters.
-Name parameter is useful to filter the network adapters by their’ name.
We can also combine this command with other commands. The below example will display the properties of the “Wi-Fi” network adapter.
PS C:\> Get-NetAdapter -Name "Wi-Fi" | Format-List
We can also retrieve other properties of network adapters using the member access operator. As you are already aware, PowerShell commands are built using .Net classes; and we can access the members of the classes using the member access operator (.).
Get-NetAdapter cmdlet is of
MSFT_NetAdapter class type; so we can access its members. The below example will display the Plug and Play Hardware ID of the network adapters.
PS C:\> (Get-NetAdapter).ComponentID
Observe that the above command is enclosed in parentheses to type cast to the right class type. Otherwise, PowerShell will throw the below message;
PS C:\> Get-NetAdapter.ComponentID Get-NetAdapter.ComponentID : The term 'Get-NetAdapter.ComponentID' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Get-NetAdapter.ComponentID + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-NetAdapter.ComponentID:String) , CommandNotFoundExceptio n + FullyQualifiedErrorId : CommandNotFoundException