Earlier I have already written about pinging from PowerShell and now this article represents using PowerShell for viewing network settings. Further tthere will be some other articles about using PowerShell in network administration.
You can view network settings using Win32_NetworkAdapterConfiguration. The Win32_NetworkAdapterConfiguration WMI class represents the attributes and behaviors of a network adapter. This class includes extra properties and methods that support the management of the TCP/IP and Internetworking Packet Exchange (IPX) protocols that are independent from the network adapter.
You can return all network adapters installed on a computer with the following command:
Get-WmiObject -Class Win32_NetworkAdapterConfiguration
Only network adapter with enabled TCP/IP:
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE
Using Win32_NetworkAdapterConfiguration, you can get a list of IP addresses of all the network adapters in your computer from Powershel
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Select-Object -Property IPAddress
Result:
IPAddress --------- {192.168.2.1} {192.168.1.3} {0.0.0.0}
Use this command if you want format command output
get-wmiobject Win32_NetworkAdapterConfiguration | format-table IPAddress, Description -autosize
Result:
IPAddress Description --------- ----------- RAS Async Adapter WAN Miniport (L2TP) WAN Miniport (PPTP) WAN Miniport (PPPOE) Direct Parallel WAN Miniport (IP) {192.168.1.2} D-Link AirPlus G DWL-G510 Wireless PCI Adapter(rev.B) - Pa... Packet Scheduler Miniport
You can also get a list of MAC addresses of network adapters
get-wmiobject Win32_NetworkAdapterConfiguration | format-table MacAddress, Description -autosize
Result:
MacAddress Description ---------- ----------- 20:41:53:59:4E:FF RAS Async Adapter WAN Miniport (L2TP) 50:50:54:50:30:30 WAN Miniport (PPTP) 33:50:6F:45:30:30 WAN Miniport (PPPOE) Direct Parallel WAN Miniport (IP) 00:11:95:FA:C6:91 D-Link AirPlus G DWL-G510 Wireless PCI Adapter(rev.B) - Pa... 00:11:95:FA:C6:91 Packet Scheduler Miniport
You can also find MAC address of a remote computer
get-wmiobject Win32_NetworkAdapterConfiguration MacAddress -ComputerName RemoteComputerName |select-object MacAddress
You must use a remote computer name or IP address instead of RemoteComputerName
To display detailed IP configuration data for each network adapter, you can use the following command:
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName .
Default command shows all properties of a network adapter. If you want to see only the TCP/IP properties, use the following command
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Select-Object -Property [a-z]* -ExcludeProperty IPX*,WINS*
This command will return detailed information about DHCP, DNS, routing, and other minor IP configuration properties. For example:
DHCPLeaseExpires : Index : 8 Description : D-Link AirPlus G DWL-G510 Wireless PCI Adapter(rev.B) - Packet Scheduler Miniport DHCPEnabled : False DHCPLeaseObtained : DHCPServer : DNSDomain : DNSDomainSuffixSearchOrder : DNSEnabledForWINSResolution : False DNSHostName : lantoolbox DNSServerSearchOrder : DomainDNSRegistrationEnabled : False FullDNSRegistrationEnabled : True IPAddress : {192.168.1.1} IPConnectionMetric : 30 IPEnabled : True IPFilterSecurityEnabled : False ArpAlwaysSourceRoute : ArpUseEtherSNAP : Caption : [00000008] D-Link AirPlus G DWL-G510 Wireless PCI Adapter(rev.B) DatabasePath : %SystemRoot%System32driversetc DeadGWDetectEnabled : False DefaultIPGateway : DefaultTOS : DefaultTTL : 64 ForwardBufferMemory : GatewayCostMetric : IGMPLevel : IPPortSecurityEnabled : IPSecPermitIPProtocols : {0} IPSecPermitTCPPorts : {0} IPSecPermitUDPPorts : {0} IPSubnet : {255.255.255.0} IPUseZeroBroadcast : KeepAliveInterval : KeepAliveTime : MACAddress : 00:11:95:FA:C6:91 MTU : NumForwardPackets : PMTUBHDetectEnabled : False PMTUDiscoveryEnabled : True ServiceName : A3AB SettingID : {85EF036E-8E68-4216-B4B4-FB075A936EEF} TcpipNetbiosOptions : 0 TcpMaxConnectRetransmissions : TcpMaxDataRetransmissions : TcpNumConnections : TcpUseRFC1122UrgentPointer : TcpWindowSize : 65535
Jul 25, 2017