Detect if a laptop is using a wifi connection

I would like to be able to detect if a laptop is using a wired connection before starting installation of huge applications, mostly CAD; some include 50 K+ files, 3+ GB package size. If it is not, and it utilizes a WiFi connection, the installation should not begin …

I can see if a WiFi adapter is installed, but I would like to see if it is actually in use.
Anybody has an idea?

This lists the WiFi adapters:
Get-Itemproperty -path ‘hklm:\System\Ccurrentcontrolset\Control\Network**\Connection’ -Erroraction SilentlyContinue | Where-Object { $_.mediasubtype -eq 2} | Select-Object -Property Name, PnpInstanceID

Something like this would work, but I wouldn’t really recommend it without you doing some modifications:

<code>$WirelessAdapters = Get-WmiObject -Class Win32_NetworkAdapter -Filter &amp;amp;quot;Description LIKE &#039;%Wireless-AC%&#039; OR Description LIKE &#039;%Advanced-N%&#039; OR Description LIKE &#039;%Ultimate-N%&#039; OR Description LIKE &#039;%WiFi%&#039; OR Description LIKE &#039;%Wi-Fi%&#039;&amp;amp;quot; # Collect all wireless adapters based on Description
$ActiveConnections = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter &amp;amp;quot;IPEnabled = $True&amp;amp;quot; # Collect all active connections
foreach($ActiveConnection in $ActiveConnections){ # loop through all active connections
    foreach($WirelessAdapter in $WirelessAdapters){ # loop through all wireless adpters
        if ( $ActiveConnection.Description -eq $WirelessAdapter.Name ){ # check if current active connection in 1st loop matches current wireless adapter.
            Write-Host &amp;amp;quot;You have an active wireless connection&amp;amp;quot; # Edit this line with your custom action.
  1. Add any wireless adapters unique description keywords you could think of that might be in use in your environment.
  2. It will only tell you if a wireless connection is active, not if it’s prioritized. I would guess wired connections will have priority over wireless but that might not be the case.

Edit: As always this forum is treating quote characters horribly. Treat every & amp ; quot ; as " and every & # 039 ; as ’ (Ctrl + H to search and replace).

Did some thinking and some googling. I came to the conclusion that Windows will prioritize the connection with the highest speed rather than media type. You will see the connection speed under the device connection status (network connections view in control panel). So if your WLAN’s Access Points’ supply slower speed than your ethernet cabled LAN it wouldn’t take a lot of effort to modify my suggestion above so that it would ignore that if you had both a wired connection and wireless active. Otherwise you will have to modify the connection metrics on your clients and that’s nothing I will dig deeper into :)…

The link below is somewhat useful:

A last note is that you will probably find much more on this on other forums, as this kind of question isn’t directly related to the PSAppDeploy toolkit :).

So I just remembered that I’ve done some work a while back with network driver upgrades and realized that it would probably be smarter to collect all wireless adapters from the drivers part of the registry.

So instead of directing you to HKLM:\SYSTEM\CurrentControlSet\Control\Class{4d36e972-e325-11ce-bfc1-08002be10318} and the subkey dword property *MediaType, I just went ahead and rewrote my earlier code. Hope it’ll be of use for you…

<code>[array]$WirelessAdapters = $null
[array]$AllNetworkDrivers = Get-ChildItem -Path &quot;HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}&quot; -ErrorAction SilentlyContinue | Where-Object {($_.Name).Substring($_.Name.Length - 4, 4) -match &quot;[0-9]&quot;}
[array]$ActiveConnections = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter &quot;IPEnabled = $True&quot; # Collect all active connections

foreach ($NetworkDriver in $AllNetworkDrivers){
    if ((Get-ItemProperty $NetworkDriver.PSPath).&quot;*MediaType&quot; -eq 16){ $WirelessAdapters += (Get-ItemProperty $NetworkDriver.PSPath).&quot;DriverDesc&quot; }

foreach($ActiveConnection in $ActiveConnections){
    foreach($WirelessAdapter in $WirelessAdapters){
        if($ActiveConnection.Description -eq $WirelessAdapter){
           Write-Host &quot;OMG - YOU HAVE AN ACTIVE WLAN CONNECTION!&quot;