1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Convert curl script to Powershell

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

  1. Misan

    Gangster

    Joined: Nov 17, 2006

    Posts: 121

    Location: Manchester

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

    Code:
    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,643

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

    https://curl.haxx.se/windows/

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

    Gangster

    Joined: Nov 17, 2006

    Posts: 121

    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.

    https://freedns.afraid.org/faq/#17

    Any ideas?
     
  4. Dj_Jestar

    Caporegime

    Joined: Oct 18, 2002

    Posts: 28,290

    Location: Back in East London

    Code:
    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