Windows 2008 Get-Netadapter equivelent

I am working on a script and trying to find a way to get the name of the network adapter on a machine in order to run some configurations. I can run netsh and get this:

Idx     Met         MTU          State                Name
---  ----------  ----------  ------------  ---------------------------
  1          50  4294967295  connected     Loopback Pseudo-Interface 1
 28           5        1500  connected     Local Area Connection 9

But I need the Local Area Connection 9 to be assigned to a variable.  The Get-Netadapter is only a Windows 8/2012 function.  Any ideas how I can get the dump of the Actual Name(Local Area Connection 9) into a variable?  Not concerned with loopback and all our servers are virtual and have only 1 interface. 

Thanks,

February 24th, 2015 10:46am

Hi,

Try this:

Get-WmiObject Win32_NetworkAdapter -Filter 'NetEnabled=True' | 
    Select Name,NetConnectionID

Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 10:52am

Great, lastly, anyway to get the NetConnectionID to be assigned to a variable that I can read in?

Thanks again Mike,

February 24th, 2015 11:25am

Without the Title, just the Local Area Connection name.
Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 11:29am

You're welcome.

I think this is what you're asking for:

$a = Get-WmiObject Win32_NetworkAdapter -Filter 'NetEnabled=True' | Select -ExpandProperty NetConnectionID

$a


February 24th, 2015 11:30am

Brilliant, thank you!!!
Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 11:32am

Cheers, glad I could help out.
February 24th, 2015 11:33am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics