PowerShell Invoke-RestMethod / CloudFlare API v4 Code Sample

If you’re looking to create your own CloudFlare API v4-based PowerShell module, and would like some syntax examples, here’s a simplified breakdown of my CloudFlareDynDns module on github, which I discuss in “Use PowerShell and CloudFlare API v4 to Dynamically Update CloudFlare DNS to your External IP“.

Chrissy is a PowerShell MVP who has worked in IT for nearly 20 years, and currently serves as a Sr. Database Engineer in Belgium. Always an avid scripter, she attended the Monad session at Microsoft’s Professional Developers Conference in Los Angeles back in 2005 and has worked and played with PowerShell ever since. Chrissy is currently pursuing an MS in Systems Engineering at Regis University and helps maintain RealCajunRecipes.com in her spare time. She holds a number of certifications, including those relating to SQL Server, SuSE Linux, SharePoint and network security. She recently became co-lead of the SQL PASS PowerShell Virtual Chapter. You can follow her on Twitter at @cl.

Posted in Networking, PowerShell
3 comments on “PowerShell Invoke-RestMethod / CloudFlare API v4 Code Sample
  1. Raimund says:

    This is an awesome script thanks. what would the syntax be to update an @ or catch all record without a prefix like http://www.?

  2. Chris Davis says:

    I love your script and it woks well, but how would I use it to update “domain.com” instead of “home.domain.com”?

    • Chris Davis says:

      I figured it out. If you add replace the “$recordurl = ” line with this code:

      if ($record) {
      $recordurl = “$baseurl/$zoneid/dns_records/?name=$record.$domain”
      } else {
      $recordurl = “$baseurl/$zoneid/dns_records/?name=$domain&type=A”
      }

      When $record = “”, it works great.

Leave a Reply

Your email address will not be published. Required fields are marked *

*