Search code examples
powershellftppowershell-7.0

Invoke-WebRequest 'ftp' scheme not supported (Powershell >7.0+)


I am trying to download a file from ftp but Invoke-WebRequest is not working. Since wget is not available on Powershell, I have to resort to use Invoke-WebRequest but I encountered this error:

Invoke-WebRequest ftp://ftp.sanger.ac.uk/pub/users/kp9/demo-vdj.h5ddl
Invoke-WebRequest: The 'ftp' scheme is not supported.

How do I resolve this for the latest version of Powershell or is there an equivalent of this to the wget command? I'm using Powershell 7.3.7. Thanks.


Solution

  • As the error message implies, Invoke-WebRequest doesn't support FTP (at least as of PowerShell (Core) 7.3.x, but I'm not aware of any plans to change that).

    You can use curl instead, which is nowadays also available on Windows.

    E.g., to download to file out.hdf

    curl ftp://ftp.sanger.ac.uk/pub/users/kp9/demo-vdj.h5ddl -o out.hdf
    

    Note:

    • In Windows PowerShell, use curl.exe, i.e. specify the filename extension explicitly, to avoid calling the built-in curl alias, which (unfortunately) refers to Invoke-WebRequest. (This alias has been removed in PowerShell (Core) 7+).