# 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