Can I configure band preference(2.4Ghz and 5Ghz) for wifi network card using GPO?

Cleiton Hoffmann 0 Reputation points
2023-08-18T23:37:07.6933333+00:00

I have 2.4Ghz and 5Ghz wifi networks, in the properties of the network card I see that it is possible to use a band preference selection to connect preferentially to networks, for example, 5Ghz. my doubt is whether in my domain environment I could apply similar configuration to all my notebooks

In my research I didn't find this type of property in the GPOS or maybe I could use some modification in the registry.

Is this possible, has anyone done something similar?

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vahid Ghafarpour 23,385 Reputation points Volunteer Moderator
    2023-08-19T00:59:41.6633333+00:00

    There is no native function for that but you can use scripts like this

    import time
    import pywifi
    
    def connect_to_network(ssid, password):
        wifi = pywifi.PyWiFi()
        iface = wifi.interfaces()[0]
        
        profile = pywifi.Profile()
        profile.ssid = ssid
        profile.auth = pywifi.const.AUTH_ALG_OPEN
        profile.akm.append(pywifi.const.AKM_TYPE_WPA2PSK)
        profile.cipher = pywifi.const.CIPHER_TYPE_CCMP
        profile.key = password
        
        iface.remove_all_network_profiles()
        tmp_profile = iface.add_network_profile(profile)
        iface.connect(tmp_profile)
    
    def main():
        preferred_ssid = "YourPreferredSSID"
        preferred_password = "YourPreferredPassword"
    
        while True:
            wifi = pywifi.PyWiFi()
            iface = wifi.interfaces()[0]
            networks = iface.scan_results()
            
            for network in networks:
                ssid = network.ssid
                band = "2.4GHz" if network.freq < 5000 else "5GHz"
                
                if ssid == preferred_ssid:
                    print(f"Connecting to preferred network: {ssid} ({band})")
                    connect_to_network(ssid, preferred_password)
                    return
            
            print("Preferred network not found. Retrying in 10 seconds...")
            time.sleep(10)
    
    if __name__ == "__main__":
        main()
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.