Hi @Pietro Guzzetti !
I tested the following script, and it ran successfully. I hope it works for you.
You will need to create a .csv file with the following information:
users,passwords
user1,password123
user2,password456
Make sure to modify the first two variables, which are the Wi-Fi network name and the path to the CSV file.
# Change here
$SSID = "YourWiFiNetwork" # Target Wi-Fi network name
$CSVPath = "C:\path\to\credentials.csv" # Path to the CSV file with credentials
$PingAddress = "8.8.8.8" # Google's DNS for connectivity test
$Credentials = Import-Csv -Path $CSVPath
foreach ($cred in $Credentials) {
$Username = $cred.Username
$Password = $cred.Password
Write-Host "`nTesting connection with username: $Username..." -ForegroundColor Yellow
# Connect to Wi-Fi using the provided credentials
$ConnectCommand = "netsh wlan connect name=$SSID user=$Username password=$Password"
Invoke-Expression $ConnectCommand
Start-Sleep -Seconds 5
$PingResult = Test-Connection -ComputerName $PingAddress -Count 2 -Quiet
if ($PingResult) {
Write-Host "Successfully connected using $Username! Internet is accessible." -ForegroundColor Green
} else {
Write-Host "Connection failed or no Internet access." -ForegroundColor Red
}
Write-Host "Disconnecting..." -ForegroundColor Yellow
netsh wlan disconnect
Start-Sleep -Seconds 3
}
Write-Host "`nTesting completed!" -ForegroundColor Cyan