Powershell to create new A Record and MX record into DNS

Powershell to Add A record and MX record into DNS. Add all the values which are given in <>

$ServerName = <DNS ServerName>

$MXrec = [WMIClass]”\\$ServerName\root\MicrosoftDNS:MicrosoftDNS_MXType”
$server = “<DNSservername>”
$OwnerName = “<domain.Example>”
$ContainerName “<domain.Example>”
$RecordClass = $Null
$TTL = $Null
$Preference = 10
$MailExchange = “mail.domain.Example”
$$MXrec.CreateInstanceFromPropertyData($ServerName, $ContainerName,’
$OwnerName, $RecordClass, $TTL, $Preference, $MailExchange

$Arec = [WmiClass]”\\$ServerName\root\MicrosoftDNS:MicrosoftDNS_AType”
$server = “<DNSservername>”
$zone = “<zoneName>”
$name = “ArecordServerAddress”
$class = 1
$ttl = 3600
$address = “IPAddress”
$Arec.CreateInstanceFromPropertydata($server, $zone, $name, $class,’
$ttl, $address)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s