However, curl may behave differently when you shift to Windows, especially in PowerShell.
This tutorial will discuss how you can use curl in PowerShell depending on the PowerShell version.
cURL on Windows – PowerShell 6.x and Above
If you are running PowerShell version 6.x and above, chances are very high that you have the cURL binary installed and available on your system.
You can check your PowerShell version with:
Name Value
---- -----
PSVersion 7.2.4
PSEdition Core
GitCommitId 7.2.4
OS Microsoft Windows 10.0.25126
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
In the output above, we can see we are running PowerShell version 7.2.4.
We can verify that we have cURL installed with the command:
curl 7.79.1 (Windows) libcurl/7.79.1 Schannel
Release-Date: 2021-09-22
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS HSTS IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI UnixSockets
We can verify we have cURL installed on our system from the output above.
As of PowerShell version 6.x, the curl command is no longer mapped to the alias of the Invoke-WebRequest command. Instead, it is a standalone binary with unique commands and operations.
cURL on Windows – PowerShell Below 6.x
In older versions of PowerShell, curl is available as an alias to the Invoke-WebRequest command.
You can verify this using the Get-Alias command:
CommandType Name
Alias curl -> Invoke-WebRequest
Notice that curl is an alias.
Using cURL as an Alias
It is no doubt that curl as an alias will have a different syntax. So, let us discuss a few examples of how to use it.
To make a simple curl request:
To view the help of how to use the utility, use the command:
Installing cURL – Older Windows Version
In some instances, you may not have cURL installed on your system. To resolve that, you can perform the following:
- Map Invoke-WebRequest to the alias curl
- Install the latest version of PowerShell, which has curl installed by default.
- Install git for windows which brings lots of tools to Windows, including curl.
- Download and install curl manually with scoop or chocolaty
Conclusion
In this article, we explored how to use curl on Windows depending on the version of PowerShell installed.
We also illustrated how to get help for curl and Invoke-WebRequest commands.