Skip to content

Instantly share code, notes, and snippets.

@markekraus
Created March 6, 2019 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markekraus/fbe1847ec15e01da7938d03180cd2fcc to your computer and use it in GitHub Desktop.
Save markekraus/fbe1847ec15e01da7938d03180cd2fcc to your computer and use it in GitHub Desktop.
Example of uploading a file with brackets in the name
New-Item -ItemType File -Path 'c:\temp\[a].txt' -value 'Test' -Force
Invoke-RestMethod -InFile 'c:\temp\`[a`].txt' -Method Post -Uri https://httpbin.org/post -ContentType 'text/plain'
<#
Result:
args :
data : Test
files :
form :
headers : @{Content-Length=4; Content-Type=text/plain; Host=httpbin.org; User-Agent=Mozilla/5.0 (Windows NT 10.0;
Microsoft Windows 10.0.17134; en-US) PowerShell/6.1.2}
json :
origin : 199.116.118.170, 199.116.118.170
url : https://httpbin.org/post
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment