### Set Cert Trust ### if ("TrustAllCertsPolicy" -as [type]) {} else { add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; } } "@ $AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12,Tls13' [System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy } ### ## Prompt the user to input the URL before the loop #$add = Read-Host "Enter the URL for all iterations" $hub = "https://ux-demo.liquidware.com/lwl/api?json=" $Reportlistpath = "C:\Liquidware_SQL\Published App REST API\UXTestURLsv2New2.txt" $Reports = Get-Content -Path $Reportlistpath $ReportOutputFolder = "C:\Liquidware_SQL\Published App REST API\Results Files" # Loop through each URL in the list for ($index = 0; $index -lt $Reports.Count; $index++) { $json = $Reports[$index] # Write-Host "URL: $url" # Generate a unique filename for each iteration $outputPath = Join-Path -Path $ReportOutputFolder -ChildPath ("Report_$index.csv") # Construct the URL $add = $hub + $json # $add = "https://ux-demo.liquidware.com/lwl/api?json=" + $json try { # Download the CSV file from the URL Invoke-WebRequest -URI $add -OutFile $outputPath # Invoke-WebRequest -URI $url -OutFile $outputPath Write-Host "File downloaded: $outputPath" } catch { Write-Host "Error downloading file: $_" } }