Disconnecting old WiFi and connecting to the new WiFi through scripting and GPO
Posted on 2016-10-06
Currently all our Win7 (Staff laptops) are connected to old wireless network..
Now we have implemented new wireless network. The Wi-Fi Security profile for the new Wi-Fi network is WPA2-Personal with AES encryption.
All the staffs Laptops are in a Laptop OU. Now when users power on their laptop, I would like their laptop to connect to the new wireless network, disconnecting the old wireless network and we don't have radius server at the moment.
First I exported the wireless profile through netsh command:
Netsh Wlan Export Profile Name="MyStaff" key=clear
I then created the batch file (Newwireless.bat) with the following code. Under Laptop OU, I created a GPO-Computer Configuration-Windows settings- Scripts- Startup and added this Newwireless.bat
IF EXIST "c:\Wireless.txt" GOTO :END
netsh wlan add profile filename="\\DC-01\NETLOGON\MyStaff.xml" user=all
When the staff Laptops are powered on, it is not disconnecting the old Wi-Fi network and connecting to the new Wi-Fi.
Please let me know if I am doing any mistake on the script and please me know if there is a way of achieving this through scripting
Any help much appreciated.
Thanks in advance.