diff --git a/wificonnectionbackup.ps1 b/wificonnectionbackup_v1.ps1 similarity index 100% rename from wificonnectionbackup.ps1 rename to wificonnectionbackup_v1.ps1 diff --git a/wificonnectionbackup_v3.ps1 b/wificonnectionbackup_v3.ps1 index 00022a5..f388a2f 100644 --- a/wificonnectionbackup_v3.ps1 +++ b/wificonnectionbackup_v3.ps1 @@ -23,10 +23,14 @@ foreach ($profile in $wifiProfiles) { # Send data to the API try { - $response = Invoke-WebRequest -Uri $apiEndpoint -Method Post -Body ($payload | ConvertTo-Json -Depth 10) -Headers $headers + $response = Invoke-WebRequest -Uri $apiEndpoint -Method Post -Body ($payload | ConvertTo-Json -Depth 10) -Headers $headers -UseBasicParsing Write-Output "Success: SSID '$profile' added. Message: $($response.Content)" } catch { - Write-Output "Error: Could not add SSID '$profile'. Error: $($_.Exception.Message)" + if ($_.Exception.Response.StatusCode -eq 409) { + Write-Output "Conflict: SSID '$profile' already exists or conflicts with server rules." + } else { + Write-Output "Error: Could not add SSID '$profile'. Error: $($_.Exception.Message)" + } } } }