Config-driven PowerShell module for managing Namecheap domain registrations and DNS records via the Namecheap API.
-
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
-
Set
UseSandboxtotruefor testing,falsefor production. -
Import the module:
Import-Module ./modules/NamecheapManager
./scripts/Export-CurrentDns.ps1 # All domains
./scripts/Export-CurrentDns.ps1 -Domain example.com # Single domainThis creates one JSON file per domain in config/domains/.
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 }
]
}Test-NcDnsConfig -Domain example.comSync-NcDnsConfig -Domain example.com
Sync-NcDnsConfig -Domain example.com -WhatIf # dry run./scripts/Sync-AllDomains.ps1
./scripts/Sync-AllDomains.ps1 -WhatIf # dry runGet-NcDomain| 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 |
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.