Last active
May 3, 2025 06:05
-
-
Save contactbrenton/6b7cefa2c6d132a770b39a32c90a6d18 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<# | |
=============================================================== | |
Wi-Fi Profile Manager Script (Windows, PowerShell) | |
=============================================================== | |
WHAT THIS SCRIPT DOES: | |
1. Lists all saved Wi-Fi profiles on the system. | |
2. Prompts the user (y/n) to delete each one individually. | |
3. Displays a list of the remaining profiles. | |
4. WARNINGS user that backups contain CLEAR TEXT passwords. | |
5. Prompts to back up remaining profiles to C:\IT\wifi. | |
6. Automatically creates C:\IT and C:\IT\wifi if needed. | |
7. Backs up profiles as .XML files (includes passwords). | |
8. Opens the backup folder in File Explorer when done. | |
IMPORTANT: | |
- Run this script as Administrator. | |
- Use with caution: Exported files contain plain-text passwords. | |
- Some Wifi profiles aren't deleted, not exactly sure why. | |
=============================================================== | |
#> | |
# Ensure script runs in Administrator mode | |
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` | |
[Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
Write-Warning "You must run this script as an Administrator." | |
exit | |
} | |
# Function to fetch current Wi-Fi profiles | |
function Get-WifiProfiles { | |
netsh wlan show profiles | Select-String "All User Profile" | ForEach-Object { | |
($_ -split ":")[1].Trim() | |
} | |
} | |
# Initial list of profiles | |
$profiles = Get-WifiProfiles | |
# Loop through each profile for optional deletion | |
foreach ($profile in $profiles) { | |
Write-Host "`nFound Wi-Fi profile: $profile" | |
$response = Read-Host "Do you want to delete this profile? (y/n)" | |
if ($response -eq 'y') { | |
netsh wlan delete profile name="$profile" | Out-Null | |
Write-Host "Deleted profile: $profile" -ForegroundColor Green | |
} else { | |
Write-Host "Skipped profile: $profile" -ForegroundColor Yellow | |
} | |
} | |
# Show remaining profiles | |
Write-Host "`n==== Remaining Wi-Fi Profiles ====" -ForegroundColor Cyan | |
$remainingProfiles = Get-WifiProfiles | |
if ($remainingProfiles.Count -eq 0) { | |
Write-Host "No Wi-Fi profiles remaining." -ForegroundColor Red | |
exit | |
} else { | |
foreach ($r in $remainingProfiles) { | |
Write-Host $r | |
} | |
} | |
# ======== SECURITY WARNING ======== | |
Write-Host "`n=============================================" -ForegroundColor Red | |
Write-Host " WARNING: BACKED UP WIFI PROFILES CONTAIN " -ForegroundColor Red | |
Write-Host " PASSWORDS IN CLEAR TEXT (VISIBLE IN XML) " -ForegroundColor Red | |
Write-Host "=============================================" -ForegroundColor Red | |
# ================================== | |
# Prompt to back up remaining profiles | |
$backupChoice = Read-Host "`nDo you want to back up the remaining profiles to C:\IT\wifi? (y/n)" | |
if ($backupChoice -eq 'y') { | |
$backupPath = "C:\IT\wifi" | |
# Create folders if they don't exist | |
if (!(Test-Path -Path "C:\IT")) { | |
New-Item -Path "C:\" -Name "IT" -ItemType "Directory" | Out-Null | |
} | |
if (!(Test-Path -Path $backupPath)) { | |
New-Item -Path "C:\IT" -Name "wifi" -ItemType "Directory" | Out-Null | |
} | |
# Export each profile to XML | |
foreach ($profile in $r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment