Trusted answers to developer questions

curl in PowerShell

Get Started With Machine Learning

Learn the fundamentals of Machine Learning with this free course. Future-proof your career by adding ML skills to your toolkit — or prepare to land a job in AI or Data Science.

curl is a command-line tool for transferring data from or to a server with any of the supported protocols including HTTP, HTTPS, FTP, and IMAP. The tool provides numerous options like resume transfer, limit bandwidth, and proxy support. curl requires minimal user interaction and is therefore preferred for automation.

curl in PowerShell uses Invoke-WebRequest. From PowerShell 3.03.0 and above, you can use Invoke-WebRequest, which is equivalent to curl.

Examples

  1. Make a web request to the educative website:
 Invoke-WebRequest -URI https://www.educative.io/
  1. Get all links on a webpage:
 (Invoke-WebRequest -Uri "https://www.educative.io/").Links.Href
  1. Submit form-data:
 $Form = @{
    firstName  = 'Bruce'
    lastName   = 'Wayne'
    email      = 'batman@wayne.com'
    occupation = 'Superhero'
 }
 $Result = Invoke-WebRequest -Uri [sample-url] -Method Post -Form $Form

Similarly, you can run more curl commands using Invoke-WebRequest.

Read more about Invoke-WebRequest here.

RELATED TAGS

powershell
curl
command
windows
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?