In PowerShell, calling Invoke-WebRequest on a local share, such as \\mydirectory\myFile.txt, will result in an error message such as Invoke-WebRequest: The 'file' scheme is not supported.. If the file is on a network share, the best alternative to Invoke-WebRequest is to simply use Copy-Item.

So:

Invoke-WebRequest \\mydirectory\myFile.txt -OutFile myFile.txt

becomes:

Copy-Item \\mydirectory\myFile.txt C:\somewherelocally\myFile.txt

I’ve seen this error with FTP also: Invoke-WebRequest: The 'ftp' scheme is not supported.

Good news is that curl is shipped with Windows 1. So we can use curl for FTP files:

curl ftp://url/mydirectory/myFile.txt -o myFile.txt

⚠️ If using PowerShell earlier than 7.0 then curl has the annoying alias back to Invoke-WebRequest. To get around this just use curl.exe and the alias will not be used.

Happy Coding 🏄‍♀️