Last active
February 16, 2023 20:41
-
-
Save misterpki/db2093b833e5b61dcc6ab76f7ef443b4 to your computer and use it in GitHub Desktop.
Add Active Directory DNS A record remotely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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