Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Active/Primary Network Adapter

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 05-22-2008   #1 (permalink)
TimParker
Guest


 

Active/Primary Network Adapter

Is there a way to tell which NIC is "active" in a PC? I am working on
writing some powershell code to sweep through my network either
through AD or through a text file (haven't added that yet) to tell me
which machines are using DHCP and what the IPs for them are and which
if any machines are using hardcoded IPs nad Gateways and such.

I have seen a few machines that the onboard nic has either stopped
working and a new NIC has been installed or where someone has
previously put in a secondary nic and I want to make sure I am getting
the one that they are actually using.

Hope that makes sense.

Thanks.

Tim

My System SpecsSystem Spec
Old 05-23-2008   #2 (permalink)
alexandair
Guest


 

Re: Active/Primary Network Adapter

This piece of code will help you start:

$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -ComputerName
$comp -Filter "IPEnabled='TRUE'"
foreach ($NIC in $NICs) {
$NIC | select
DNSHostName,DNSDomain,IPAddress,IPSubnet,DefaultIPGateway,DHCPEnabled,Description,MACAddress
}

The crucial part is the filter "IPEnabled='TRUE'" which will give you
"alive" NICs. If NIC has more than one IP address assigned, property
IPAddress will be an array of IP addresses. You can do $nic | fl * to
find is there any other property that you might find helpful.

-aleksandar
http://powershellers.blogspot.com


On May 23, 2:24*am, TimParker <tim...@xxxxxx> wrote:
Quote:

> Is there a way to tell which NIC is "active" in a PC? I am working on
> writing some powershell code to sweep through my network either
> through AD or through a text file (haven't added that yet) to tell me
> which machines are using DHCP and what the IPs for them are and which
> if any machines are using hardcoded IPs nad Gateways and such.
>
> I have seen a few machines that the onboard nic has either stopped
> working and a new NIC has been installed or where someone has
> previously put in a secondary nic and I want to make sure I am getting
> the one that they are actually using.
>
> Hope that makes sense.
>
> Thanks.
>
> Tim
My System SpecsSystem Spec
Old 05-23-2008   #3 (permalink)
TimParker
Guest


 

Re: Active/Primary Network Adapter

Perfect. I just ran this on my workstation at home that currently is
not in a domain and got a couple errors based on that (which I
expected to see)

the IPEnabled is the magic field I was looking for! Thanks for the
info!

Tim


On May 23, 3:29 am, alexandair <alexand...@xxxxxx> wrote:
Quote:

> This piece of code will help you start:
>
> $NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -ComputerName
> $comp -Filter "IPEnabled='TRUE'"
> foreach ($NIC in $NICs) {
> $NIC | select
> DNSHostName,DNSDomain,IPAddress,IPSubnet,DefaultIPGateway,DHCPEnabled,Description,MACAddress
>
> }
>
> The crucial part is the filter "IPEnabled='TRUE'" which will give you
> "alive" NICs. If NIC has more than one IP address assigned, property
> IPAddress will be an array of IP addresses. You can do $nic | fl * to
> find is there any other property that you might find helpful.
>
> -aleksandarhttp://powershellers.blogspot.com
>
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to index network files AND not fill your primary drive Jesper Hauge Vista file management 0 08-26-2008 03:58 PM
Network Adapter Hangs When Transferring/Streaming from Network ConFUZEd Wulf Network & Internet 12 07-05-2008 08:25 PM
two active network connections mokeur Vista networking & sharing 6 05-19-2008 04:19 PM
What partition becomes the Active one by default on the primary di Henrik Vista installation & setup 0 02-04-2008 01:40 AM
3Com Wireless adapter not active JW Vista hardware & devices 2 08-17-2007 10:48 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51