0
Invoke-WebRequest -Headers $headers -Method "POST" -Uri $uri -InFile $fileToAttach

In the above web request:

  • $uri points to a public website.
  • $fileToAttach points to a remote file share (Access via VPN).
  • My connection is public internet (home internet), connected to above VPN to access the file share.

When I run this command, does the $fileToAttach download to my PC (in memory?) and then the file is sent to $uri? If not, what is the chain of events that happens?

Jeremy
  • 3
  • 1

1 Answers1

0

A quick test with Wireshark showed that Invoke-WebRequest, in order:

  1. Starts a TCP connection to the destination server $uri
  2. Loads the entire -InFile file from the remote server into memory,
  3. Continues with the connection in 1, processing https/auth steps,
  4. Posts the file
Cpt.Whale
  • 4,784
  • 1
  • 10
  • 16