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>
source
share