Aug 12 2021 03:50 PM
The output that I see on the console looks different from what gets redirected to the file
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Basic Put BASE64 encoded value of username:password")
$response = Invoke-WebRequest 'https://abc123.com/feeds/feed_ipv4' -Method 'GET' -Headers $headers
$response.content
#------------------------------
$response.content | set-content -Path "C:\inetpub\wwwroot\abc.com\feed_IPV4.txt"
$response.content | out-file -FilePath "C:\inetpub\wwwroot\abc.com\feed_IPV4.txt"
Below is what is see in console for $response.content
1.1.1.1-1.1.1.10
2.2.2.2-2.2.2.20
Below is what is written to file by either set-content or out-file
1.1.1.1-1.1.1.102.2.2.2-2.2.2.20
How can I solve this.
Aug 13 2021 01:30 PM
Solution
Try to use
Write-Output
$response.content | Write-Output >> "C:\inetpub\wwwroot\abc.com\feed_IPV4.txt"
Aug 13 2021 03:24 PM
Aug 13 2021 01:30 PM
Solution
Try to use
Write-Output
$response.content | Write-Output >> "C:\inetpub\wwwroot\abc.com\feed_IPV4.txt"