Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Store Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems.

Go Back   Vista Forums > Vista technology newsgroups > PowerShell

Is network available?

Reply
 
Thread Tools Display Modes
Old 04-15-2008   #1 (permalink)
ajax76
Guest
 
Posts: n/a

Is network available?

Hello all.

Is it best way to check that network available?

if([Net.NetworkInformation.NetworkInterface]::GetIsNetworkAvailable())
{
(New-Object Net.NetworkInformation.Ping).Send('google.com').Status}

Thanks for attention.
  Reply With Quote

Old 04-15-2008   #2 (permalink)
Hal Rottenberg
Guest
 
Posts: n/a

Re: Is network available?

ajax76 wrote:
Quote:

> Is it best way to check that network available?
>
> if([Net.NetworkInformation.NetworkInterface]::GetIsNetworkAvailable())
Just based on what I see from calling the GetAllNetworkInterfaces() static
method on the same class and doing some quick tests, I would say this is not a
foolproof test. According to MSDN:

"A network connection is considered to be available if any network interface is
marked "up" and is not a loopback or tunnel interface."

One of the two VPN tunnel drivers I'm using don't seem to mark itself as such,
or the above is not otherwise reliable because when I unhooked my NIC cable just
now (no wifi link either), GetIsNetworkAvailable() was still true.
Quote:

> (New-Object Net.NetworkInformation.Ping).Send('google.com').Status}
Otherwise, I'd say a ping to the Internet is always good if that's the criteria
you care about. I usually go the WMI route and look at
win32_networkadapterconfiguration, but your way seems to work just fine.

--

Hal Rottenberg
Blog: http://halr9000.com
Webmaster, Psi (http://psi-im.org)
Co-host, PowerScripting Podcast (http://powerscripting.net)
  Reply With Quote
Old 04-15-2008   #3 (permalink)
ajax76
Guest
 
Posts: n/a

Re: Is network available?

Can I say that .NET does not provide a simple and reliable method for
such verification.
  Reply With Quote
 
Reply

Thread Tools
Display Modes









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