Skip to content

Instantly share code, notes, and snippets.

@jmcker
Last active September 30, 2023 15:27
Show Gist options
  • Save jmcker/d620cc0d1ba955e187aa767d43d70b5c to your computer and use it in GitHub Desktop.
Save jmcker/d620cc0d1ba955e187aa767d43d70b5c to your computer and use it in GitHub Desktop.
Bulk import/export of Windows wireless network profiles.
netsh wlan export profile key=clear
Get-ChildItem "." -Filter *.xml |
Foreach-Object {
$content = Get-Content $_.FullName
# Only import if it has a key
# We don't need open networks
if ($content -like "*keyMaterial*") {
Write-Output "Importing ${_}"
netsh wlan add profile filename="${_}"
if ($LastExitCode -ne 0) {
""
Write-Output "Failed to import ${_}!" -Foreground Red
""
}
""
} else {
Write-Output "Skipped ${_}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment