Automating with PowerShell: Deploying WiFi Profiles

I’m working with one of my collaborators to create scripts for their RMM system and they got a request from one of their clients “Can we add WiFi profiles using PowerShell?” and of course I pointed them to my blog. Only to find to my shame that I never blogged about it.

Adding WiFi profiles is very straight forward when you’re using a domain environment, you simply create a GPO and click around in the settings until you’ve perfected your setup, but in modern styled environments it’s not always that easy, and of course you want to use your RMM system to deploy the correct Wi-Fi Settings to all users.

So, let’s jump into that; today we’re adding a Wifi Connecting that uses a WPA2 PSK with AES encryption – The most commonly used network these days.

The Script

You’ll have to set $SSID and $PSK to your prefered SSID and PSK, remember that the SSID is case sensitive too.

$guid = New-Guid
$HexArray = $ssid.ToCharArray() | foreach-object { [System.String]::Format("{0:X}", [System.Convert]::ToUInt32($_)) }
$HexSSID = $HexArray -join ""
<?xml version="1.0"?>
<WLANProfile xmlns="">
	<MacRandomization xmlns="">
"@ | out-file "$($ENV:TEMP)\$guid.SSID"

netsh wlan add profile filename="$($ENV:TEMP)\$guid.SSID" user=all

remove-item "$($ENV:TEMP)\$guid.SSID" -Force

And that’s it! using this script you can deploy Wi-Fi to your clients with relative ease 🙂 As always, Happy PowerShelling.


  1. Michael McCool April 21, 2021 at 4:52 pm

    Here is a Windows 7 compatible version of the XML. If you support Windows 7 devices still, the above will likely not work with them. This XML will work for both Windows 7 and 10.






  2. Jimbo June 28, 2021 at 3:31 pm

    Thanks for this! It solved my problem nicely. As post-lockdown (ish) people are starting to work in our office again, users haven’t been able to connect to the office wifi for various reasons. I can’t give them the password (company policy), nor can I do it via remote access to their machines, as configuring a new connection kills the current connection.
    Top tip – the wifi password I’ve been dealing with has an ampersand in it (&), which breaks your script. The solution was to replace it with the html special character &

  3. Jimbo June 28, 2021 at 3:36 pm

    Ugh – auto-formatting on my comment above has mucked up my explanation! The very last character is not a simple & – instead of me fiddling about, search in Google for ‘html special characters &’ and you’ll see the string I meant under the ‘Replacement’ column

  4. stephen July 21, 2021 at 9:26 pm

    Awesome script working perfectly.

    Just curious, could you shed some insight on how to edit this to add multiple WiFI profiles?

    I found that I could wrap the entire code block into a Function, create a function for each wifi profile, then call each function and it works as intended.

    I’m just interested in how you could clean it up. Great stuff!

  5. jmac August 18, 2021 at 5:57 pm

    I must be a bit dumb/blind but where do you actually set the SSID and PSK in the script?

    1. Fred September 3, 2021 at 9:40 pm

      This seems to work for me:


Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.