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 Cloud and Datacenter Management & Data Platform MVP who has worked in IT for over 20 years. She is the creator of the popular SQL PowerShell module dbatools, and holds a number of certifications, including those relating to SQL Server, Linux, SharePoint and network security. 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 *

*