How to connect to Wi-Fi in powershell, knowing the SSID and password?

How to connect to Wi-Fi in PowerShell in the same way as through the GUI, but using code? what commands do i use? I know the SSID and password.

EDIT: I never connected to it, so this is new wifi.

+8
source share
2 answers
netsh wlan connect ssid=YOURSSID name=PROFILENAME

it should be...

EDIT: try this, it just worked for me :)

netsh wlan connect ssid="YOURSSID" key="YOURPW"
+4
source

This is not Powershell, but it works in every version 10 (currently 1903). I have a package and XML on a flash drive with which I run it. With it, I do not need to remember or write down the password / key in the XML file.

Batch file:

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

WhwhatYouWantToCallIt.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>
0
source

Source: https://habr.com/ru/post/1608797/


All Articles