[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 119
  • Last Modified:

Disconnecting old WiFi and connecting to the new WiFi through scripting and GPO

Hi

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
@echo off

IF EXIST "c:\Wireless.txt" GOTO :END

netsh wlan add profile filename="\\DC-01\NETLOGON\MyStaff.xml" user=all

echo >>"c:\Wireless.txt"

:END

EXIT

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.
0
lianne143
Asked:
lianne143
  • 4
  • 3
4 Solutions
 
Muhammad MullaCommented:
I'm not sure there's a way in GPO to remove the old network. However, there is a way to create a new connection and have the device automatically connect under

Computer Configuration > Policies > Security Settings > Wireless Network (802.11) Policies

https://technet.microsoft.com/en-us/library/gg266419.aspx?f=255&MSPPError=-2147217396
0
 
John HurstBusiness Consultant (Owner)Commented:
Do a netsh wlan delete profile filename=... after you have added the new one.
0
 
lianne143Author Commented:
It must connect to the new WiFi and delete the old WiFi. But it is not even connecting to the new WiFi.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
John HurstBusiness Consultant (Owner)Commented:
Is the computer able to get to the server path if no wireless connection?

Did you double check the XML file for correct credentials?
0
 
lianne143Author Commented:
The computer is able to get the server path details and also the XML has the correct details.
If i copy the file to the desktop and run from there, will that work before i copy it to the GPO.
0
 
John HurstBusiness Consultant (Owner)Commented:
I would certainly try importing from a local file instead of server
0
 
lianne143Author Commented:
Ok will copy this file to the laptop and run the batch file and post the results.
0
 
John HurstBusiness Consultant (Owner)Commented:
Thanks for the update.
0

Featured Post

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now