0

We've been seeing intermittent issues with users connecting to wifi. It seems that this may be due to interference, with the recommended solution being to change the RoamingPreferredBandType to 5GHz.

Per this thread, this can be done by amending the registry setting RoamingPreferredBandType's value to 2. Some code (for both bat and powershell have been included on that thread; but these seem to scan through a large chunk of the registry finding and updating all properties with this value. Whilst it's pretty unlikely that other entries will have a property with this name, I don't like code that works on assumptions; and this approach isn't overly efficient. Is there a better way to do this, targeting only those entries that matter?

1 Answer 1

0

This is a modified version of the script on the Intel forum thread (linked in the question), which takes advantage of a couple of things to improve on their script:

  • The GUID {4D36E972-E325-11CE-BFC1-08002BE10318} is always the one which will have network adapters under it, helping us narrow down the registry path: https://technet.microsoft.com/en-us/library/jj130901.aspx
  • We can get the device id/index of a network adapter from the WMI class Win32_NetworkAdapter, which combined with the above gives us the full path to our adapter's registry key.

.

Get-WmiObject -Class Win32_NetworkAdapter | ?{$_.Name -like '*Wireless*'} | %{("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{{4D36E972-E325-11CE-BFC1-08002BE10318}}\{0:0000}" -f ([int]$_.Index))} | %{ 
    if(get-itemproperty -Path $_ -Name 'RoamingPreferredBandType' -ErrorAction SilentlyContinue) {
        Set-ItemProperty -Path $_ -Name 'RoamingPreferredBandType' -Value 2    
    } else {
        New-ItemProperty -Path $_ -Name 'RoamingPreferredBandType' -PropertyType String -Value 2
    }
}

i.e.

  • get a list of all network adapters
  • filter for the wireless ones
  • use the device id / index of each wireless adapter to get the full registry path for this device/these devices
  • for each device found, check if the RoamingPreferenceBandType property exists:
    • If so, set it to 2 (if it doesn’t exist this will create it).
    • If not, create a new one with value 2 (this scenario’s unlikely; but best to cater for)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .