We are attempting to replace an existing wifi network that uses standard RADIUS. With a new network uses PSK without RADIUS for authentication. The goal is to get our fleet of Windows devices (mostly 10s, and a few 11s) to switch over to the new network automatically and keep it as the preferred network until the user selects a different network.
To this end, we are pushing a Wi-Fi profile using an Intune OMA-URI template device configuration profile. The wifi profile XML used in the config was exported from a device that was successfully connected to the network, and if the profile is imported to a new device. That device does successfully connect to the network with-out prompting for the PSK. But it does not automatically select the new network as preferred, so devices that have successfully applied the profile are still connecting to the old network first.
Since the script didn't appear to be setting the preferred network, I decided to try fixing it with Intune remediation. But the script it is running doesn't appear to be setting the new network as the preferred connection.
I get a trigger from the detection script like I would expect, but the remediation script doesn't appear to be doing what it is expected to do.
When I run the remediation script manually on a test device, the network priority is correctly set. But the device still connects to the old network.
We have also tried setting the priority using group policy. But that just broke the profile from Intune. Once the network was removed from the policy, devices receiving it would connect as expected.
Below I've included the detection and remediation scripts. Does anyone have any idea why my test devices would not be connecting to their preferred wif profile, or alternately a better/more elegant way to accomplish what we are trying to do?