Author Posts

January 1, 2012 at 12:00 am

by fangol at 2013-02-01 01:51:42

Hi, I'm a beginner and I wondered if anyone could help me with this? I'm trying to create a PoSH script that will check whether the Virtual NIC status is Connected. Once the NIC is connected it just needs to exit. Any advice greatly appreciated!

by Klaas at 2013-02-01 04:36:11

Do you want this only on your own machine, on a remote machine or on a collection of machines?
What do you mean by The virtual NIC? There can be a lot of them.
With WMI you can learn a lot from networkadapter and networkadapterconfiguration classes:
Get-WMI -computername mypc -class win32_networkadapter
Get-WMI win32_networkadapterconfiguration | Select *

by fangol at 2013-02-01 07:58:43

Hey thanks for your help, I figured it out, in this particular case there is a legacy adapter and a virtual adapter. I needed to know when the virtual adapter is up, I know once it has a default gateway that it is up so I did it this way. This works because the legacy adapter does not have a default gateway. Thanks for the tip.

do{Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object{$_.description -like "*Virtual*"}|Select description,DefaultIPGateway}
until ($_DefaultIPGateway -like "*192*")