To add a new DNS record on a Windows Server 2022 using PowerShell, you can use the Add-DnsServerResourceRecord
cmdlet. Here is a step-by-step guide:
-
Open PowerShell with Administrator privileges:
- Right-click the Start button and select “Windows PowerShell (Admin)”.
-
Use the
Add-DnsServerResourceRecord
cmdlet:-
The syntax for adding a DNS A record is as follows:
Add-DnsServerResourceRecordA -Name "<RecordName>" -ZoneName "<ZoneName>" -IPv4Address "<IPAddress>"
-
Replace
<RecordName>
with the name of the DNS record you want to add. -
Replace
<ZoneName>
with the name of your DNS zone (e.g., “example.com“). -
Replace
<IPAddress>
with the IP address associated with the DNS record.
-
-
Example:
-
To add an A record for
test.example.com
with an IP address of192.168.1.100
in theexample.com
zone, you would run:Add-DnsServerResourceRecordA -Name "test" -ZoneName "example.com" -IPv4Address "192.168.1.100"
-
-
Confirm the record:
-
You can confirm that the DNS record has been added successfully by querying the DNS server. Use the
Resolve-DnsName
cmdlet to check the record:Resolve-DnsName test.example.com
-
This command should return the IP address 192.168.1.100
if the record was added correctly.