Last updated on Jun 29, 2017
The purpose of this article is to show case how to add a new A record to a DNS zone using PowerShell.
Here is a quick look at the available Syntax for : Add-DnsServerResourceRecordA
Add-DnsServerResourceRecordA [-AllowUpdateAny] [-CreatePtr] [-Name] <String> [-IPv4Address] <IPAddress[]> [-ComputerName <String>] [-TimeToLive <TimeSpan>] [-ZoneName] <String> [-AgeRecord] [-PassThru] [-ZoneScope <String>] [-VirtualizationInstance <String>] [-CimSession <CimSession[]>] [-ThrottleLimit <Int32>] [-AsJob] [-WhatIf] [-Confirm] [<CommonParameters>]
Now lets look at a quick example:
1 2 |
Add-DnsServerResourceRecordA -Name Nerd01 -ZoneName ThatLazyAdmin.local -AllowUpdateAny -IPv4Address 10.10.20.30 -TimeToLive 01:00:00 |
Let’s add this is a quick small script:
1 2 3 4 5 6 7 8 |
$ErrorActionPreference = [crayon-67abe7cdba022993625023 inline="true" ]'Continue' $dnsrecord = Read-Host 'Enter New ARecord Name' $zonename = Read-Host 'Enter Zone Name' $ip = Read-Host 'Enter IPv4 Address' Write-Host -NoNewline "New Record Created:"-ForegroundColor Yellow Add-DnsServerResourceRecordA -Name $dnsrecord -ZoneName $zonename -AllowUpdateAny -IPvAddress $ip -TimeToLive 01:00:00 Write-Host 'ARecord:'$dnsrecord,'DNS-Zone:'$zonename,'IPv4:'$ip -ForegroundColor Green |
[/crayon]
#ThatLazyAdmin
Be First to Comment