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

前端 未结 2 553
旧巷少年郎
旧巷少年郎 2021-02-04 07:34

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

2条回答
  •  别跟我提以往
    2021-02-04 08:13

    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:

    
    
        SSIDSHOULDGOHERE
        
            
                XXXXXX
                SSIDGOESHERE
            
        
        ESS
        auto
        
            
                
                    WPA2PSK
                    AES
                    false
                
                
                    passPhrase
                    false
                    PASSWORDGOESHERE
                
            
        
        
            false
        
    
    

提交回复
热议问题