{"id":11114,"date":"2024-11-14T12:02:05","date_gmt":"2024-11-14T10:02:05","guid":{"rendered":"https:\/\/lazyadmin.nl\/?p=11114"},"modified":"2024-11-14T12:02:08","modified_gmt":"2024-11-14T10:02:08","slug":"using-curl","status":"publish","type":"post","link":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/","title":{"rendered":"How to use cURL in PowerShell"},"content":{"rendered":"\n<p>The command-line tool cURL (client URL) is commonly used to send or receive data to a server. The tool&#8217;s advantage is that it supports multiple protocols and offers features like authentication, proxy, transfer resume, and more.<\/p>\n\n\n\n<p>We can also use cURL in PowerShell, but there are a few important things that you need to know. And PowerShell also has it&#8217;s own methods to transfer data to and from servers.<\/p>\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">In this article<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69f6f7c082c68\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\" style='display:none' id=\"ez-toc-cssicon-toggle-item-69f6f7c082c68\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#powershell-curl\" >PowerShell cURL<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#removing-the-alias-curl\" >Removing the Alias cURL<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#using-curl-in-powershell\" >Using cURL in PowerShell<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#basic-get-request\" >Basic GET Request<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#sending-data\" >Sending Data<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#using-authentication\" >Using Authentication<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#wrapping-up\" >Wrapping Up<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<p>In this article, I will explain how you can use cURL in PowerShell, and give you some examples.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"powershell-curl\"><\/span>PowerShell cURL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>cURL has been around since 1997 and is used to interact with web services, to send or retrieve data. The tool is commonly used in scripting or to automate tasks. Naturally, you might want to use cURL in your PowerShell scripts as well.<\/p>\n\n\n\n<p>Now before we can use cURL in PowerShell there is one important thing that you need to know. Up to PowerShell 6, the command cURL has been an alias in PowerShell for the cmdlet <code>Invoke-WebRequest<\/code>. This caused many issues\/confusions, so since PowerShell 6, the command cURL now actually calls the curl.exe utility.<\/p>\n\n\n\n<p>We can see this by looking up the command with the <code>Get-Command<\/code> cmdlet in both PowerShell 5 and PowerShell 7:<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"487\" height=\"210\" data-id=\"11116\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/curl-powershell-53.jpg\" alt=\"curl PowerShell 5.1\" class=\"wp-image-11116\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/curl-powershell-53.jpg 487w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/curl-powershell-53-300x129.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/curl-powershell-53-400x172.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/curl-powershell-53-50x22.jpg 50w\" sizes=\"(max-width: 487px) 100vw, 487px\" \/><figcaption class=\"wp-element-caption\">PS 5.1<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"487\" height=\"210\" data-id=\"11115\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/curl-PowerShell-7.jpg\" alt=\"curl PowerShell 7\" class=\"wp-image-11115\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/curl-PowerShell-7.jpg 487w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/curl-PowerShell-7-300x129.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/curl-PowerShell-7-400x172.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/curl-PowerShell-7-50x22.jpg 50w\" sizes=\"(max-width: 487px) 100vw, 487px\" \/><figcaption class=\"wp-element-caption\">PS 7<\/figcaption><\/figure>\n<\/figure>\n\n\n\n<p>As you can see, the command curl call the curl.exe in PowerShell 7, just like we expect. But in PowerShell 5.1, the command is actually an alias.<\/p>\n\n\n\n<p>The problem with this is that the whole syntax of the <code>Invoke-WebRequest<\/code> cmdlet is different from cURL, so your commands won&#8217;t work as you expect.<\/p>\n\n\n\n<p>cURL is installed on Windows 10\/11 by default, but if you don&#8217;t have cURL installed, then you can <a href=\"https:\/\/curl.se\/windows\/\">download it here<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"removing-the-alias-curl\"><\/span>Removing the Alias cURL<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you want to use the real cURL command-line utility in PowerShell 5.1, then you have two options. You can use curl.exe as a command, or remove the alias. I prefer the latter because this will make sure that your scripts also work on PowerShell 7. To remove the alias you can use the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Remove-Item alias:curl<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"using-curl-in-powershell\"><\/span>Using cURL in PowerShell<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>So let&#8217;s take a look at some examples of how to use cURL in PowerShell. In the example below I will show the true cURL method and the PowerShell version, <code>Invoke-WebRequest<\/code> to give you a better understanding of the differences.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"basic-get-request\"><\/span>Basic GET Request<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>To simply get the contents of a specific URL, we can use the commands below.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl https:\/\/httpbin.org\/ip<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Invoke-WebRequest -Uri \"https:\/\/httpbin.org\/ip\"\n\n# In this case it's better to use, because the output is in JSON\nInvoke-RestMethod https:\/\/httpbin.org\/ip<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"sending-data\"><\/span>Sending Data<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The httpbin endpoint that I am using in the examples below will just return the data that we send to it, but this is perfect in this example. To send data with cURL, we need to set the HTTP method to POST.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl -X POST https:\/\/httpbin.org\/anything -d \"test=data\"<\/pre>\n\n\n\n<p>The Invoke-WebRequest method uses the same principle, only with a different syntax:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$body = \"test=data\"\nInvoke-WebRequest -Uri \"https:\/\/httpbin.org\/anything\" -Method POST -Body \"test=data\"<\/pre>\n\n\n\n<p>In the examples above we only send a single value to the endpoint, but more common is to submit a form or send multiple fields to the endpoint. In cURL we can do this by specifying the fields using the -F  parameter. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># POST form data with multiple fields\ncurl -X POST https:\/\/httpbin.org\/post `\n  -F \"name=John Doe\" `\n  -F \"email=john@example.com\" `\n  -F \"message=Hello World\"\n\n# Or for a JSON payload\ncurl -X POST https:\/\/httpbin.org\/post -H \"Content-Type: application\/json\" `\n  -d '{\"field1\":\"value1\",\"field2\":\"value2\",\"field3\":\"value3\"}'<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"774\" height=\"266\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/image-3.png\" alt=\"powershell post form with curl command\" class=\"wp-image-11120\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/image-3.png 774w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/image-3-300x103.png 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/image-3-768x264.png 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/image-3-400x137.png 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/image-3-50x17.png 50w\" sizes=\"(max-width: 774px) 100vw, 774px\" \/><\/figure>\n\n\n\n<p>When using the <code>Invoke-WebRequest<\/code> method, we can first create a hashtable with the formdata that we want to post. And to keep the code readable, we can also use a hashtable and <a href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-hashtable\/\">splatting<\/a> to store all the parameters<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$formData = @{\n    name = \"John Doe\"\n    email = \"john@example.com\"\n    message = \"Hello World\"\n}\n\n$post = @{\n    Uri = \"https:\/\/httpbin.org\/post\"\n    Method = 'Post'\n    Body = $formData\n}\n\nInvoke-WebRequest @post<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"using-authentication\"><\/span>Using Authentication<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Most APIs require a form of authentication to be able to transfer data with it. When it comes to authentication there are different methods, but basic authentication (username &amp; password) or bearer token authentication are the most commonly used options.<\/p>\n\n\n\n<p>To use basic authentication with cURL, you will need to pass the username and password in the format <code>username:passwor<\/code>d. In the example below we will add the username and password as well in the URL, but that is only for testing purposes:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl -u \"username:password\" https:\/\/httpbin.org\/basic-auth\/username\/password\n\n# returns on succesfull authentication\n{\n  \"authenticated\": true,\n  \"user\": \"username\"\n}<\/pre>\n\n\n\n<p>When using the PowerShell method, <code>Invoke-WebRequest<\/code>, we first need to create a credential object. You can ask the user to input the credentials, with the <code>Get-Credential<\/code> cmdlet, but when you want to store the credentials in your script, you will need to convert them to a secure string first:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Get the credentials from the user\n$Credentials = Get-Credential -UserName \"username\" -Message \"Enter your password\"\n\n# Or store the credentials in the script\n$Password = ConvertTo-SecureString \"password\" -AsPlainText -Force\n$Credentials = New-Object System.Management.Automation.PSCredential (\"username\", $Password)\n\nInvoke-WebRequest -Uri \"https:\/\/httpbin.org\/basic-auth\/username\/password\" -Credential $Credentials\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"wrapping-up\"><\/span>Wrapping Up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>It&#8217;s a good thing that Microsoft removed the cURL alias in PowerShell 7, because eventhough cURL and Invoke-WebRequest may look similar, cURL has a lot more capabilites. If you are creating scripts that are going to run on other machines, then you can use the command <code>curl.exe<\/code> to be sure that cURL is used instead of Invoke-WebRequest.<\/p>\n\n\n\n<p>Hope you liked this article, if you have any questions, just drop a comment below.<\/p>\n<script async src=\"https:\/\/alatus.eocampaign1.com\/form\/d0ce5de8-9b48-11ee-8cf4-eb425eea7369.js\" data-form=\"d0ce5de8-9b48-11ee-8cf4-eb425eea7369\"><\/script>","protected":false},"excerpt":{"rendered":"<p>The command-line tool cURL (client URL) is commonly used to send or receive data to a server. The tool&#8217;s advantage is that it supports multiple protocols and offers features like authentication, proxy, transfer resume, and more. We can also use &#8230; <a title=\"How to use cURL in PowerShell\" class=\"read-more\" href=\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/\">Read more<span class=\"screen-reader-text\">How to use cURL in PowerShell<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":11121,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[69],"tags":[22],"class_list":["post-11114","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-powershell"],"wppr_data":{"cwp_meta_box_check":"No"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to use cURL in PowerShell &#8212; LazyAdmin<\/title>\n<meta name=\"description\" content=\"What you need to know about using cURL in PowerShell and how it compares to Invoke-WebRequest cmdlet, including examples\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use cURL in PowerShell &#8212; LazyAdmin\" \/>\n<meta property=\"og:description\" content=\"What you need to know about using cURL in PowerShell and how it compares to Invoke-WebRequest cmdlet, including examples\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/\" \/>\n<meta property=\"og:site_name\" content=\"LazyAdmin\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/lazyadminnl\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/lazyadminnl\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-14T10:02:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-14T10:02:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"677\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rudy Mens\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/lazyadmin\" \/>\n<meta name=\"twitter:site\" content=\"@lazyadmin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rudy Mens\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/\"},\"author\":{\"name\":\"Rudy Mens\",\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\"},\"headline\":\"How to use cURL in PowerShell\",\"datePublished\":\"2024-11-14T10:02:05+00:00\",\"dateModified\":\"2024-11-14T10:02:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/\"},\"wordCount\":742,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\"},\"image\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg\",\"keywords\":[\"Powershell\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/\",\"url\":\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/\",\"name\":\"How to use cURL in PowerShell &#8212; LazyAdmin\",\"isPartOf\":{\"@id\":\"https:\/\/lazyadmin.nl\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg\",\"datePublished\":\"2024-11-14T10:02:05+00:00\",\"dateModified\":\"2024-11-14T10:02:08+00:00\",\"description\":\"What you need to know about using cURL in PowerShell and how it compares to Invoke-WebRequest cmdlet, including examples\",\"breadcrumb\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#primaryimage\",\"url\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg\",\"contentUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg\",\"width\":1200,\"height\":677,\"caption\":\"PowerShell cURL\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lazyadmin.nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use cURL in PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lazyadmin.nl\/#website\",\"url\":\"https:\/\/lazyadmin.nl\/\",\"name\":\"LazyAdmin\",\"description\":\"Tips and howto&#039;s about Office 365, PowerShell, Home network and smart devices\",\"publisher\":{\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/lazyadmin.nl\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\",\"name\":\"Rudy Mens\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg\",\"contentUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg\",\"width\":500,\"height\":500,\"caption\":\"Rudy Mens\"},\"logo\":{\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/\"},\"description\":\"Ruud worked for more than 15 years as a SysAdmin in the Netherlands and is now working as an independent consultant. In his spare time, he loves to thinker with Smart Devices.\",\"sameAs\":[\"https:\/\/lazyadmin.nl\",\"https:\/\/www.facebook.com\/lazyadminnl\/\",\"http:\/\/nl.linkedin.com\/in\/rudymens\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/lazyadmin\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use cURL in PowerShell &#8212; LazyAdmin","description":"What you need to know about using cURL in PowerShell and how it compares to Invoke-WebRequest cmdlet, including examples","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/","og_locale":"en_US","og_type":"article","og_title":"How to use cURL in PowerShell &#8212; LazyAdmin","og_description":"What you need to know about using cURL in PowerShell and how it compares to Invoke-WebRequest cmdlet, including examples","og_url":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/","og_site_name":"LazyAdmin","article_publisher":"https:\/\/www.facebook.com\/lazyadminnl\/","article_author":"https:\/\/www.facebook.com\/lazyadminnl\/","article_published_time":"2024-11-14T10:02:05+00:00","article_modified_time":"2024-11-14T10:02:08+00:00","og_image":[{"width":1200,"height":677,"url":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg","type":"image\/jpeg"}],"author":"Rudy Mens","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/lazyadmin","twitter_site":"@lazyadmin","twitter_misc":{"Written by":"Rudy Mens","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#article","isPartOf":{"@id":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/"},"author":{"name":"Rudy Mens","@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952"},"headline":"How to use cURL in PowerShell","datePublished":"2024-11-14T10:02:05+00:00","dateModified":"2024-11-14T10:02:08+00:00","mainEntityOfPage":{"@id":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/"},"wordCount":742,"commentCount":2,"publisher":{"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952"},"image":{"@id":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#primaryimage"},"thumbnailUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg","keywords":["Powershell"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/lazyadmin.nl\/powershell\/using-curl\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/","url":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/","name":"How to use cURL in PowerShell &#8212; LazyAdmin","isPartOf":{"@id":"https:\/\/lazyadmin.nl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#primaryimage"},"image":{"@id":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#primaryimage"},"thumbnailUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg","datePublished":"2024-11-14T10:02:05+00:00","dateModified":"2024-11-14T10:02:08+00:00","description":"What you need to know about using cURL in PowerShell and how it compares to Invoke-WebRequest cmdlet, including examples","breadcrumb":{"@id":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lazyadmin.nl\/powershell\/using-curl\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#primaryimage","url":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg","contentUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg","width":1200,"height":677,"caption":"PowerShell cURL"},{"@type":"BreadcrumbList","@id":"https:\/\/lazyadmin.nl\/powershell\/using-curl\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lazyadmin.nl\/"},{"@type":"ListItem","position":2,"name":"How to use cURL in PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/lazyadmin.nl\/#website","url":"https:\/\/lazyadmin.nl\/","name":"LazyAdmin","description":"Tips and howto&#039;s about Office 365, PowerShell, Home network and smart devices","publisher":{"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lazyadmin.nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952","name":"Rudy Mens","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/","url":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg","contentUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg","width":500,"height":500,"caption":"Rudy Mens"},"logo":{"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/"},"description":"Ruud worked for more than 15 years as a SysAdmin in the Netherlands and is now working as an independent consultant. In his spare time, he loves to thinker with Smart Devices.","sameAs":["https:\/\/lazyadmin.nl","https:\/\/www.facebook.com\/lazyadminnl\/","http:\/\/nl.linkedin.com\/in\/rudymens\/","https:\/\/x.com\/https:\/\/twitter.com\/lazyadmin"]}]}},"uagb_featured_image_src":{"full":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg",1200,677,false],"thumbnail":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4-150x150.jpg",150,150,true],"medium":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4-300x169.jpg",300,169,true],"medium_large":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4-768x433.jpg",768,433,true],"large":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4-1024x578.jpg",1024,578,true],"1536x1536":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg",1200,677,false],"2048x2048":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg",1200,677,false],"post-thumb":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4-800x451.jpg",800,451,true],"post-thumb-half":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4-400x226.jpg",400,226,true],"wppr-widget":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4-50x28.jpg",50,28,true],"gform-image-choice-sm":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg",300,169,false],"gform-image-choice-md":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg",400,226,false],"gform-image-choice-lg":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/11\/PowerShell-4.jpg",600,339,false]},"uagb_author_info":{"display_name":"Rudy Mens","author_link":"https:\/\/lazyadmin.nl\/author\/lajcud8123b\/"},"uagb_comment_info":2,"uagb_excerpt":"The command-line tool cURL (client URL) is commonly used to send or receive data to a server. The tool&#8217;s advantage is that it supports multiple protocols and offers features like authentication, proxy, transfer resume, and more. We can also use ... Read moreHow to use cURL in PowerShell","_links":{"self":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/posts\/11114"}],"collection":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/comments?post=11114"}],"version-history":[{"count":0,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/posts\/11114\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/media\/11121"}],"wp:attachment":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/media?parent=11114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/categories?post=11114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/tags?post=11114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}