Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to a wifi in powershell knowing the SSID and password?

How can I connect to a wifi in powershell just like through GUI but by using code? what commands do I use? I know the SSID and the password.

EDIT: I have never connected to it before so it is a new wifi.

like image 928
John Smith Avatar asked Sep 24 '15 11:09

John Smith


People also ask

How do I find my Wi-Fi password using PowerShell?

Display WiFi Password via PowerShell Command Line Interface After listening to the Wireless profiles and SSID we will use the netsh wlan show profile "name=SSID" key=clear command in order to display the wireless password in clear text mode.

How do I login with SSID and password?

Enter your new wireless name in the Name (SSID) field and enter your new WiFi password in the Password (Network Key) field. Click Apply in the upper right-hand corner. After the settings have been applied you will need to reconnect your wireless devices to your router using your new network login information.


2 Answers

netsh wlan connect ssid=YOURSSID name=PROFILENAME

this should be it...

EDIT: Try this, just worked for me :)

netsh wlan connect ssid="YOURSSID" key="YOURPW"
like image 115
JanMer Avatar answered Oct 07 '22 17:10

JanMer


This isn't Powershell, but it works in every version of 10 so far (currently on 1903). I have the batch and XML on a flash drive that I run it from. With it in the xml file, I don't have to remember or write down the password/key.

Batch file:

Netsh WLAN delete profile "SSID"
Netsh WLAN add profile filename=".\WhateverYouWantToCallIt.XML"
Netsh WLAN connect name="$NAME"

WhateverYouWantToCallIt.XML file:

<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
    <name>SSIDSHOULDGOHERE</name>
    <SSIDConfig>
        <SSID>
            <hex>XXXXXX</hex>
            <name>SSIDGOESHERE</name>
        </SSID>
    </SSIDConfig>
    <connectionType>ESS</connectionType>
    <connectionMode>auto</connectionMode>
    <MSM>
        <security>
            <authEncryption>
                <authentication>WPA2PSK</authentication>
                <encryption>AES</encryption>
                <useOneX>false</useOneX>
            </authEncryption>
            <sharedKey>
                <keyType>passPhrase</keyType>
                <protected>false</protected>
                <keyMaterial>PASSWORDGOESHERE</keyMaterial>
            </sharedKey>
        </security>
    </MSM>
    <MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
        <enableRandomization>false</enableRandomization>
    </MacRandomization>
</WLANProfile>
like image 24
0ldphart Avatar answered Oct 07 '22 17:10

0ldphart