1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice
Hey Guest, we are running a Photoshop competition with a 32" monitor as the first prize - See here for details.

Convert curl script to Powershell

Discussion in 'HTML, Graphics & Programming' started by Misan, Oct 29, 2018.

  1. Misan


    Joined: Nov 17, 2006

    Posts: 123

    Location: Manchester

    Hi guys - I've got a curl script I'd like to create an equivalent PS script for Windows machines.

    curl -b "dns_cookie=XXXXXXXXXX" -d "type=TXT" -d "subdomain=_acme-challenge" -d "domain_id=0000" -d "data_id=0000" -d "address=%22some_text%22" https://freedns.afraid.org/subdomain/save.php?step=2
    I'm looking to do dns-01 challenges automatically by scripting the TXT record creation with my DNS provider.

    Hopefully someone with better knowledge of PS can help.

    Many thanks
  2. howler

    Wise Guy

    Joined: Oct 5, 2004

    Posts: 1,647

    you can get curl on windows so just run it in a batch / powershell


    if you want the output in a file just add "> C:\temp\filename.txt"
  3. Misan


    Joined: Nov 17, 2006

    Posts: 123

    Location: Manchester

    Many thanks for the reply. I’ve installed curl - however when testing my script in it just seems to pull down the content of the Freedns page and my TXT record is not created.

    Clearly there is something amiss in my syntax - I’ve inputted the dns_cookie correctly and my data_id is set correctly for the subdomain in question.

    Here’s the FAQ on the freedns site for reference.


    Any ideas?
  4. Dj_Jestar


    Joined: Oct 18, 2002

    Posts: 28,348

    Location: Back in East London

    Invoke-WebRequest -Method POST -Body @{ dns_cookie='XXXXXXXXXX'; type='TXT'; subdomain='_acme-challenge'; domain_id='0000'; address='%22some_text%22' } -Uri https://freedns.afraid.org/subdomain/save.php?step=2