I know the pos has been idle for a while, but I thought I would share my PowerShell script for configuring wif on machines.
I have recently been working on scripts for our wireless in the office. The script below is how I push out a new Wi-Fi signal through our current RMM system. I connect to the wireless signal and use the netsh to export the profile to the XML file. If you copy the contents of your wifi signal and place it between the bolded lines. Change the reference on the bottom that are
My_WiFi_Signal to match your signal name. You could leave out the Start wait command or connect command if you do not want the script to try to connect at the time.
$XmlContent = @'
<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>My_WiFi_Signal</name>
<SSIDConfig>
<SSID>
<hex>4E43494120436C69656E74</hex>
<name>My_WiFi_Signal</name>
</SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>auto</connectionMode>
<MSM>
<security>
<authEncryption>
<authentication>WPA3SAE</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey>
<keyType>passPhrase</keyType>
<protected>false</protected>
<keyMaterial>the_plain_text_wifi_passcode_is_in_this_location</keyMaterial>
</sharedKey>
</security>
</MSM>
<MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
<enableRandomization>false</enableRandomization>
<randomizationSeed>3158460945</randomizationSeed>
</MacRandomization>
</WLANProfile>
'@
$XmlFilePath = "wifi_
My_WiFi_Signal.xml"
$XmlContent | Set-Content -Path $XmlFilePath
# Import the WiFi profile using netsh
netsh wlan add profile filename="$XmlFilePath"
# Set the profile to automatically connect
netsh wlan set profileparameter name="
My_WiFi_Signal" connectionmode=auto
# Wait for 3 Seconds before connecting to
My_WiFi_Signal
# Start-Sleep -Seconds 3
# Connect to the new WiFi profile
netsh wlan connect name="
My_WiFi_Signal"
# Delete the XML file
Remove-Item -Path $XmlFilePath
Make sure to completely replace the
orange text with your data.
I can't take a lot of the credit, other than I knew what I wanted and looked for assistance compiling the script with ChatGPT. But made my life simpler since we are getting to turn of the current Wi-Fi that connects to our main network, because someone decided to publish all the wireless passwords and thought they pay attention to what to use on what. When I pushed this, I also had a command to delete the old signal, though it did now work consistently.
--Corey