Prior to creating a new Web Application in our SharePoint 2010 environment, I would like to add a host A record to DNS so that the URL we assign to our web application is directed to the appropriate IP Address. I will create a new address record for ‘lab.ps4sp.com’ and associate it to

In this example, I have the following setup:

    Domain Name: PS4SP.com

    Domain Controller Name: PS-DC

    SharePoint Server Name: PS-SPS

    SharePoint Server IP:

In figure 1 below, you should be able to confirm these details.

Figure 1

In order to accomplish this task in PowerShell, we will use MicrosoftDNS_AType, which is a subclass of MicrosoftDNS_ResourceRecord that represents a host Address (A) record. We then use the CreateInstanceFromPropertyData to create the address record.

DnsServerName [in]

Fully Qualified Domain Name (FQDN) or IP address of the DNS Server that contains this RR.

ContainerName [in]

Name of the Container for the Zone, Cache, or RootHints instance which contains this RR.

OwnerName [in]

Owner FQDN for the RR.

Note  Do not use the owner NetBIOS name.

RecordClass [in, optional]

Class of the RR. Default value is 1. The following values are valid.

TTL [in, optional]

Time, in seconds, that the RR can be cached by a DNS resolver.

IPAddress [in]

String representing the IP address of the host.

RR [out]

Reference to the new object.

The Script


# Set the FQDN of the domain controller

$dnsServer = “ps-dc.ps4sp.com”

# Set the dns zone name of where to place the host A record

$dnsZone = “ps4sp.com”

# Set the name of the Host A

$hostA = “lab.ps4sp.com”

# Set the class: 1 = Internet, 2 = CSNet, 3 = CHAOS, 4 = Hesiod

$class = 1

# Set the TTL, time that the RR can be cached

$ttl = 3600

# Set the IP Address of the destination

$IPAddress = “”

# Assign the MicrosoftDNS_AType

$dnsAType = [wmiclass]“\$dnsServerrootMicrosoftDNS:MicrosoftDNS_AType”

# Use CreateInstanceFromPropertyData to create the host A record

$dnsAType.CreateInstanceFromPropertyData($DNSserver, $dnsZone, $hostA, $class, $ttl, $IPAddress)

The Results


Figure 2 shows how the script looks inside PowerShell ISE. Figure 3 show the results of the command inside the DNS Manager.

Figure 2

Figure 3


2 thoughts on “Add a Host ‘A’ Record Using PowerShell

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