curl in PowerShell

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.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved