Skip to content
PowerShell module for converting Curl commands to PowerShell
PowerShell
Branch: master
Clone or download
ThePoShWolf Merge pull request #24 from ThePoShWolf/parser
Switched from regular expressions to using a parser
Latest commit ada3353 Oct 11, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github adding an issue template Apr 26, 2019
Tests updated the tests to actually work Oct 11, 2019
build/Curl2PS built 0.0.3 Oct 11, 2019
docs initial doc commit Mar 29, 2019
src switched to system.uri Oct 11, 2019
.gitattributes Initial commit Mar 7, 2019
Curl2PS.build.ps1 built 0.0.3 Oct 11, 2019
LICENSE Updating license copyright name Oct 11, 2019
Module.PSDeploy.ps1 Added the deploy settings May 8, 2019
README.md Updated readme May 8, 2019
build.ps1 Fixed a c/p typo Apr 5, 2019
notes.ps1 built 0.0.3 Oct 11, 2019

README.md

Curl2PS

This module is a utility module to help convert curl commands to Invoke-RestMethod syntax.

This module includes classes for dealing with the curl command as well as URLs, but primarily converts curl commands to Invoke-RestMethod syntax with the ConvertTo-IRM function.

To install the module:

Install-Module Curl2PS

Usage examples:

$CurlString = @"
curl -H "X-Auth-Key: 61e5f04ca1794253ed17e6bb986c1702" -H "X-Auth-Workspace: demo.example@actualreports.com" -H "X-Auth-Signature: " -H "Content-Type: application/json" -H "Accept: application/json" -X GET https://us1.pdfgeneratorapi.com/api/v3/templates
"@

PS> $splat = ConvertTo-IRM $CurlString
PS> Invoke-RestMethod @splat

Or if you'd prefer the string command:

ConvertTo-IRM $CurlString -String

Invoke-RestMethod -Uri https://us1.pdfgeneratorapi.com/api/v3/templates -Method GET -Headers @{
    'X-Auth-Key' = '61e5f04ca1794253ed17e6bb986c1702'
    'Accept' = 'application/json'
    'X-Auth-Signature' = ''
    'X-Auth-Workspace' = 'demo.example@actualreports.com'
    'Content-Type' = 'application/json'
}

Or another example:

PS> ConvertTo-IRM -CurlCommand 'curl --request GET "https://ncg1in-8d1rag:5nuauzj5pkfftlz3fmyksmyhat6j35kf@api.sherpadesk.com/tickets?status=open,onhold&role=user&limit=6&format=json"  --data ""' -String

Invoke-RestMethod -Uri https://api.sherpadesk.com/tickets -Method GET -Headers @{
    'Authorization' = 'Basic bmNnMWluLThkMXJhZzo1bnVhdXpqNXBrZmZ0bHozZm15a3NteWhhdDZqMzVrZg=='
}

Issues

If you find a curl command that doesn't properly convert, please open an issue!

PRs welcome!

You can’t perform that action at this time.