Set Wi-Fi settings automatically

Unattended will create your profile before Post-Setup (Machine) rolls by. I suspect the combination of switching to manual user creation (to check ipconfig /all) and the bogus /S combined to break both cases.

What happens when you go back to Unattended user accounts + (no /S) in Machine execution?
Just tried %WINDIR% again with Machine execution. I made sure to adjust the commands accordingly, and I made sure the .xml profile was added in Machine execution as well. Still not working. Hard-coding the path is the only way I've gotten it to work.
 
OK, I figured out what the problem *actually* was. When I came into work today, I noticed the machines were hanging on "Connecting" after a fresh install with my NTLite image, just like they were when I first asked my questions. I got so wrapped up in a small portion of the problem, I forgot what the original issue was! I had a hunch the problem was in fact the wifi profile xml file, and lo and behold, it was. I re-exported my profile with key=clear, and things just worked.

From reading online guides about wifi profiles on Windows, it appeared you didn't have to export your profiles with plaintext passwords, but at least in my case, I had to. In hindsight it makes sense, otherwise you could just grab wifi profiles off of any machine and instantly have access to any network without actually being given access. I'm too lazy to look into if the profiles are just hashing the password, or if there's actually some sort of encryption going on - things are working as I want them to, and I'm happy with that.

%WINDIR% works without an issue. I believe Machine and User execution both work, but I have everything in User execution just for simplicity since I was having issues with some unrelated commands when in Machine execution.

Thank you to all who helped. I hope this thread helps someone else in the future!
 
OK, I figured out what the problem *actually* was. When I came into work today, I noticed the machines were hanging on "Connecting" after a fresh install with my NTLite image, just like they were when I first asked my questions. I got so wrapped up in a small portion of the problem, I forgot what the original issue was! I had a hunch the problem was in fact the wifi profile xml file, and lo and behold, it was. I re-exported my profile with key=clear, and things just worked.

From reading online guides about wifi profiles on Windows, it appeared you didn't have to export your profiles with plaintext passwords, but at least in my case, I had to. In hindsight it makes sense, otherwise you could just grab wifi profiles off of any machine and instantly have access to any network without actually being given access. I'm too lazy to look into if the profiles are just hashing the password, or if there's actually some sort of encryption going on - things are working as I want them to, and I'm happy with that.

%WINDIR% works without an issue. I believe Machine and User execution both work, but I have everything in User execution just for simplicity since I was having issues with some unrelated commands when in Machine execution.

Thank you to all who helped. I hope this thread helps someone else in the future!
I tried to export with key=clear and xmls are exactly same
Today il try to manually enter my password and build iso
 
I tried to export with key=clear and xmls are exactly same
Today il try to manually enter my password and build iso
Interesting, you're adding key=clear when you're running netsh wlan export, correct? The XML files should not be the same. On the several machines I've tested on, the XML exported with key=clear shows me the plaintext version of my SSID password in the XML file, whereas the standard export shows me a hashed version of the password.
 
Interesting, you're adding key=clear when you're running netsh wlan export, correct? The XML files should not be the same. On the several machines I've tested on, the XML exported with key=clear shows me the plaintext version of my SSID password in the XML file, whereas the standard export shows me a hashed version of the password.
yes i figured it out i think something was wrong in terminal but only difference is these 2 changes

<protected>false</protected> # instead of true
<keyMaterial>the password</keyMaterial>
 
yes i figured it out i think something was wrong in terminal but only difference is these 2 changes

<protected>false</protected> # instead of true
<keyMaterial>the password</keyMaterial>
Glad you figured it out. Those two lines are the only parts that differ for me as well.
 
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
 
This self-contained script does the same job, but doesn't abstract the Wi-Fi config to an external file. This may be an important factor for some organizations that have several networks. For them, swapping out the profile is easier than rewriting the script for each network.

But for a single-network setup, it's fine.
 
Back
Top