Last active
September 30, 2023 15:27
-
-
Save jmcker/d620cc0d1ba955e187aa767d43d70b5c to your computer and use it in GitHub Desktop.
Bulk import/export of Windows wireless network profiles.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
netsh wlan export profile key=clear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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