Jump to content

Recommended Posts

Posted

I've pushed out our new wifi settings with a Powershell script which adds the new network and deletes the old one (which is due to be turned off) 

Only problem is that computers don't 'Connect automatically' to the new network, users need to select that toggle. Anyone know of a way to force this? 

(I can't use the GPO because WPA3 isn't supported on Server 2016)

Posted

param(
    [string]$SSID="school ssid",
    [string]$PSK="long key"
)
$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="http://www.microsoft.com/networking/WLAN/profile/v1">
    <name>$($SSID)</name>
    <SSIDConfig>
        <SSID>
            <hex>$($HexSSID)</hex>
            <name>$($SSID)</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>$($PSK)</keyMaterial>
            </sharedKey>
        </security>
    </MSM>
    <MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
        <enableRandomization>false</enableRandomization>
        <randomizationSeed>1451755948</randomizationSeed>
    </MacRandomization>
</WLANProfile>
"@ | out-file "$($ENV:TEMP)\$guid.SSID"

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

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

Posted

is the delete of old profile done somewhere else as can't see a delete in that script ?
 

could you try adding:

netsh wlan connect name="$($SSID)"

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...