I am trying to upload a file [path] to [uri] with Invoke-WebRequest with the following:
$Uri = [uri]
$Body = @{
username = $Credentials.UserName
password = $Credentials.Password
file = Get-Item -Path [path]
}
Invoke-WebRequest -Uri $Uri -Method 'POST' -Body $Body -UseBasicParsing
(As I'm stuck with Powershell 5.1 I include -UseBasicParsing).
This leads to a failed login response, and inspecting the server response, I see that it interprets the password string as "System.Security.SecureString" instead of the actual password.
I assume that this happens because -UseBasicParsing changes how SecureString objects are passed? I am a complete novice in Powershell and HTTP and so would greatly appreciate any suggestions for workarounds that don't compromise on security, and/or any explanations for why this happens.