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
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.
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!!!
February 24th, 2015 11:32am
Cheers, glad I could help out.
February 24th, 2015 11:33am