Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2016-10-06
8
Medium Priority
?
109 Views
Last Modified: 2016-10-19
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
Comment
Question by:lianne143
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 10

Accepted Solution

by:
Muhammad Mulla earned 1000 total points
ID: 41831607
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
 
LVL 98

Assisted Solution

by:John Hurst
John Hurst earned 1000 total points
ID: 41831767
Do a netsh wlan delete profile filename=... after you have added the new one.
0
 

Author Comment

by:lianne143
ID: 41832026
It must connect to the new WiFi and delete the old WiFi. But it is not even connecting to the new WiFi.
0
Technology Partners: 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!

 
LVL 98

Assisted Solution

by:John Hurst
John Hurst earned 1000 total points
ID: 41832033
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
 

Author Comment

by:lianne143
ID: 41832107
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
 
LVL 98

Assisted Solution

by:John Hurst
John Hurst earned 1000 total points
ID: 41832123
I would certainly try importing from a local file instead of server
0
 

Author Comment

by:lianne143
ID: 41832131
Ok will copy this file to the laptop and run the batch file and post the results.
0
 
LVL 98

Expert Comment

by:John Hurst
ID: 41850553
Thanks for the update.
0

Featured Post

Q2 2017 - Latest Malware & Internet Attacks

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out our latest Quarterly Internet Security Report!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
What monsters are hiding in your child's room? In this article I will share with you a tech horror story that could happen to anyone, along with some tips on how you can prevent it from happening to you.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question