DCSIMG
QuickTip: How do you check Internet connectivity? - Shay Levy

Shay Levy

If you repeat it, PowerShell it!

QuickTip: How do you check Internet connectivity?

With the following PowerShell one-liner you can check if the machine you’re working on has internet connectivity. The result is a Boolean value. If TRUE, the local machine is connected to the internet; if FALSE, it is not.

Minimum supported client: Windows Vista

[Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet

Comments

Ohad Israeli said:

At least give some credit to the original source where you can find the full solution

blogs.msdn.com/.../setting-network-location-to-private.aspx

# March 9, 2010 2:36 PM

ScriptFanatic said:

I've lost track of my source. Thank you for revealing it.

# March 9, 2010 3:47 PM

Rob Wiley said:

This only works for Vista and above.

# March 9, 2010 11:39 PM

Cameron Ove said:

Wow Ohad,

Does that mean that, when I spend 5 or 6 hours discovering a .Net class and reading TechNet and MSDN and I come up with a solution that also appears on the Windows PowerShell Blog, I am plagiarizing?

The article you referenced doesn't even mention 'IsConnectedToInternet'.  Which would indicate that Shay did some discovery of that object on his own.

As a matter of fact someone commented on that script by Vladimir Averkin on that page who gave him a correction.  That alone is an indicator that many people have similar knowledge that they've accumulated by their own research over the years.  So just because it is similar is not an indicator that it was plagiarized.  

Plagiarism is a serious accusation and you really should have facts before you go around spewing accusations.

Personally I think your comment is in poor taste and somewhat offensive.  Which is why I posted this comment.  

# March 21, 2010 3:42 PM

John Henry said:

Yes, it doesn't work on Windows XP and 2003

Exception calling "CreateInstance" with "1" argument(s): "Retrieving the COM class factory for component with CLSID {DCB00C01-570F-4A9B-8D69-199FDBA5723B} failed due to the fol

lowing error: 80040154."

At C:\Temp\d445497e-8069-458e-9a08-125034ba392d.ps1:1 char:28

+ [Activator]::CreateInstance <<<< ([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet

   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

   + FullyQualifiedErrorId : DotNetMethodException

# April 14, 2011 8:51 AM

ScriptFanatic said:

It doesn't suppose to work on XP/2003, only on Vista and above (it is written in the post).

# April 14, 2011 9:59 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: