PowerShell for Windows Admins

Sep 6 2010   12:47PM GMT

WMI and Network Adapters: 4

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

We have looked at using Win32_NetworkAdapter and Win32_NetworkAdapterConfiguration. 

Get-WmiObject -Class Win32_NetworkAdapter -Filter "NetEnabled=’$true’" |
Format-List NetConnectionID, Description, MACAddress, Speed

Get-WmiObject -Class Win32_NetworkAdapterConfiguration |
where {$_.IPAddress} | Foreach { $_.Description; $_ |
select -ExpandProperty IPAddress}

Now we need to look at combining the information from the two classes. One way to do it is like this

001
002
003
004
005
006
007
008
009
010
011
012
Get-WmiObject -Class Win32_NetworkAdapter -Filter "NetEnabled=’$true’" | 
foreach {
 $_ | Format-List NetConnectionID, Description, MACAddress, Speed 

 $filt = "Index=’" + $_.DeviceID + "’"
 $nic = `
 Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter $filt 
 
 $nic | Format-List DefaultIPGateway, IPSubnet, DNSServerSearchOrder
 "IP Address"
 $nic | select -ExpandProperty IPAddress
}

This doesn’t give the most elegant of results so we will need to refine what we are doing

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: