commit c6b45c632191d5fd20a10baaa0380c7417360607 Author: cole@cybertek.systems Date: Tue Dec 24 12:50:40 2024 -0600 First Commit diff --git a/wificonnectionbackup.ps b/wificonnectionbackup.ps new file mode 100644 index 0000000..ed0fb33 --- /dev/null +++ b/wificonnectionbackup.ps @@ -0,0 +1,32 @@ +# Create output folder if it doesn't exist +$folderPath = "C:\Tech" +if (-Not (Test-Path -Path $folderPath)) { + New-Item -ItemType Directory -Path $folderPath +} + +# Get WiFi profiles +$wifiProfiles = netsh wlan show profiles | Select-String "All User Profile" | ForEach-Object { ($_ -split ":")[1].Trim() } + +# Initialize array for WiFi data +$wifiData = @() + +foreach ($profile in $wifiProfiles) { + # Extract PSK if available + $profileData = netsh wlan show profile name="$profile" key=clear | Select-String "Key Content" | ForEach-Object { ($_ -split ":")[1].Trim() } + + # Only add profiles with a PSK to the array + if ($profileData) { + $wifiData += [PSCustomObject]@{ + SSID = $profile + PSK = $profileData + } + } +} + +# Export data to CSV +$csvPath = Join-Path -Path $folderPath -ChildPath "wifi_data.csv" +$wifiData | Export-Csv -Path $csvPath -NoTypeInformation + +# Export data to JSON +$jsonPath = Join-Path -Path $folderPath -ChildPath "wifi_data.json" +$wifiData | ConvertTo-Json | Out-File -FilePath $jsonPath