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

落爺英雄遲暮 提交于 2019-12-03 12:42:23
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"

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>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!