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)