Ajouter wifilock.ps1

This commit is contained in:
2025-10-06 07:57:20 +00:00
commit f829e60308

24
wifilock.ps1 Normal file
View File

@@ -0,0 +1,24 @@
# Nom du réseau autorisé
$allowedSSID = "ProfsH3"
# Obtenir la liste des profils Wi-Fi enregistrés
$wifiProfiles = netsh wlan show profiles | Select-String "Profil Tous les utilisateurs" | ForEach-Object {
($_ -split ":")[1].Trim()
}
# Supprimer tous les profils sauf "ProfsH3"
foreach ($profile in $wifiProfiles) {
if ($profile -ne $allowedSSID) {
Write-Output "Suppression du profil Wi-Fi : $profile"
netsh wlan delete profile name="$profile"
}
}
# Désactivation de la connexion automatique aux nouveaux réseaux
netsh wlan set blockednetworks display=show
netsh wlan add filter permission=denyall networktype=infrastructure
# Autoriser uniquement le réseau "ProfsH3"
netsh wlan add filter permission=allow ssid="$allowedSSID" networktype=infrastructure
Write-Host "`n✅ Seul le réseau Wi-Fi '$allowedSSID' est désormais autorisé." -ForegroundColor Green