Skip to content

Instantly share code, notes, and snippets.

@misterpki
Last active February 16, 2023 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misterpki/db2093b833e5b61dcc6ab76f7ef443b4 to your computer and use it in GitHub Desktop.
Save misterpki/db2093b833e5b61dcc6ab76f7ef443b4 to your computer and use it in GitHub Desktop.
Add Active Directory DNS A record remotely
$credential = Get-Credential
Invoke-Command -ComputerName "domaincontroller.example.com" -Credential $credential -ScriptBlock {
$hostname = Read-Host -Prompt "Enter host name"
$ip = Read-Host -Prompt "Enter IP Address"
Write-Host "Creating A Record for host '$hostname' having IP '$ip'"
Add-DNsServerResourceRecordA -Name $hostname `
-ZoneName "example.com" `
-AllowUpdateAny `
-IPv4Address $ip `
-ComputerName "domaincontroller.example.com" `
-CreatePtr `
-TimeToLive "300" `
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment