Reliably disabling internet access on Windows 7 and up
<p>I'm trying to write a script that requires turning off the Internet entirely and then turning it back on. I'd like it to work in as many cases as possible...</p>

<ul>
<li>support for Window 7 and up</li>
<li>if multiple Internet connections are on (like WiFi and LAN)</li>
<li>regardless of how these connections are named</li>
<li>limited user account, UAC?</li>
</ul>

<p><code>ipconfig /release</code> and <code>ipconfig /renew</code>, as suggested in <a href="https://superuser.com/a/846520/365353">this answer</a>, do not work with 2 internet connections. <code>/release</code> disables the active connection (say WLAN) but the computer falls back on the LAN connection and you're still online.</p>



<pre><code>$connectedAdapters = Get-WmiObject -Class Win32_NetworkAdapter -Filter "NetConnectionStatus = 2"
$connectedAdapters | Invoke-WmiMethod -Name disable
</code></pre>

<p>My questions are:</p>

<ul>
<li><p>Is <code>NetConnectionStatus = 2</code> a reliable proxy for internet access, and is it available on Windows 7 and up, regardless of the brand of your NIC?</p></li>
<li><p>Is this compatible with a limited user account with UAC on? I think so...</p></li>
<li><p>On my machine this query also catches VirtualBox Host-Only Ethernet Adapter. Is it a problem if I disable/enable it too?</p></li>
<li><p>Are <code>Get-WmiObject</code> and <code>Invoke-WmiMethod</code> are available on Windows 7 and up, right?</p></li>
</ul>