Skip to content

Mike-Crowley/PSNamecheap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSNamecheap

Config-driven PowerShell module for managing Namecheap domain registrations and DNS records via the Namecheap API.

Setup

  1. Copy the settings template and fill in your Namecheap API credentials:

    Copy-Item config/settings.json.example config/settings.json
    # Edit config/settings.json with your API credentials
  2. Set UseSandbox to true for testing, false for production.

  3. Import the module:

    Import-Module ./modules/NamecheapManager

Usage

Export current DNS to config files

./scripts/Export-CurrentDns.ps1              # All domains
./scripts/Export-CurrentDns.ps1 -Domain example.com  # Single domain

This creates one JSON file per domain in config/domains/.

Edit DNS config

Edit the JSON files in config/domains/. Example:

{
  "Domain": "example.com",
  "Records": [
    { "Type": "A",     "Name": "@",   "Address": "1.2.3.4",   "TTL": 1800 },
    { "Type": "CNAME", "Name": "www", "Address": "example.com.", "TTL": 1800 },
    { "Type": "MX",    "Name": "@",   "Address": "mail.example.com.", "MXPref": 10, "TTL": 1800 },
    { "Type": "TXT",   "Name": "@",   "Address": "v=spf1 include:_spf.google.com ~all", "TTL": 1800 }
  ]
}

Preview changes (dry run)

Test-NcDnsConfig -Domain example.com

Sync a single domain

Sync-NcDnsConfig -Domain example.com
Sync-NcDnsConfig -Domain example.com -WhatIf  # dry run

Sync all domains

./scripts/Sync-AllDomains.ps1
./scripts/Sync-AllDomains.ps1 -WhatIf  # dry run

List domains

Get-NcDomain

Module Functions

Function Description
Get-NcDomain List all domains in your account
Get-NcDnsRecord Get current DNS records for a domain
Set-NcDnsRecord Push DNS records to a domain (full replace)
Test-NcDnsConfig Compare config file to live DNS, show diff
Sync-NcDnsConfig Push config file DNS records to Namecheap

API Access

Enable API access in your Namecheap account under Profile > Tools > Namecheap API Access. Whitelist your IP address there as well. See the Namecheap API docs for details.

About

Config-driven PowerShell module for managing Namecheap domains and DNS records. Define desired state in JSON, preview diffs, and sync.

Topics

Resources

Stars

Watchers

Forks

Contributors