Each operating system has its type of commands to perform administrative, support or management or daily use tasks. Some of these commands may be compatible between all systems, but most are not. One case of this is cURL, which we can use frequently in macOS, UNIX or Linux environments, but not in Windows, talking about versions before 5 of PowerShell ..
cURL is a command that is used frequently through command lines or scripts to transfer data to a computer. But even beyond this, cURL is used in other elements such as cars, televisions, routers or printers in order to execute the transfer of data from the Internet.
cURL is a free and open source software and its scope is so high that it supports protocols and files such as: DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, Telnet and TFTP, is also able to support SSL certificates, HTTP POST, HTTP PUT, FTP upload, HTTP based upload, proxies, HTTP / 2, cookies, authentication Username + password (Basic, Normal, Summary, CRAM-MD5, NTLM, Negotiate and Kerberos), curriculum transfer file, proxy tunneling and much more..
In order to use cURL in Windows PowerShell, in this case on Windows 10, we must validate the version of PowerShell which must be at least 5, to verify this we will execute the following:
$ PSVersionTable.PSVersion
By using cURL in Windows PowerShell we will give more functionality to this modern Microsoft management console.
1. How to use cURL in Windows PowerShell
To test cURL in Windows PowerShell, it will be possible to write a cURL command as one that downloads a file from a GitHub repository.
Step 1
For this case we can execute the following:
curl http://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/mongodb-on-ubuntu/azuredeploy.json> azuredeploy3.json}
We can see that this error is generated, but there is cURL being used as an alias. The aliases in Windows PowerShell give us the possibility to create shortcuts for more extensive commands in order not to enter all the complete syntax..
Step 2
We can use the Get-Alias ​​cmdlet and we will see the following. Let's note that on the line the cURL command is responsible for calling the Invoke-WebRequest command.
Step 3
So that for cURL functions in the ideal way, just edit the syntax we have executed and it will only be necessary to execute the following in this case:
“Https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/mongodb-on-ubuntu/azuredeploy.jsonâ€
Step 4
Thus, in this way, we can use cURL in Windows PowerShell. We can see that the file has been downloaded in the indicated path, in this case System32 because PowerShell was run as administrator, worse we can choose the desired path:
2. How to delete a Windows alias
Step 1
In the case that we do not have a profile in Windows PowerShell, the first step to take will be to create one by running the following command:
New-Item $ profile -force -itemtype file
Step 2
Now, we will open this profile in the text editor by running the following:
notepad $ profile
In the deployed file we will paste the following. There we proceed to save the changes and close the notebook.
remove-item alias: curl
Next, we must execute the following command to reload the profile, or close and reopen Windows Powershell to update the changes.
3. Alternatives to install cURL on Windows
Step 1
A practical method to ensure that cURL is installed in our system is by accessing the following link and downloading there:
cURL for Windows
Another way to install cURL is using Chocolatey which can be analyzed in detail in the following link:
Chocolate and
Chocolatey is a Linux-like command-line package manager for Windows systems. We will open PowerShell as administrators and execute the following command:
iex ((new-object net.webclient) .DownloadString ('https://chocolatey.org/install.ps1'))
Step 2
Once we have installed Chocolatey, we can use it to install cURL and we must open and close PowerShell before this to apply the changes.
We will execute the following to install cURL. There we can run the script or not.
choco install curl
Step 3
Once the process is finished we will see the following:
CURL tips
Below, we will see some useful tips on how to use cURL on Windows, and generally on other systems:
Basic Syntax:
curl http: // url --output "Output file"
Hide the cURL progress indicator: The cURL progress indicator allows us to see in detail the current progress of the download, if we want to hide it we can use the -so –silent parameter as well.
curl http://solvetic.com --output File –silent
Thus, we have seen several alternatives to install and use cURL in Windows PowerShell and take full advantage of this command.