In the last part of the script I am creating for MIM 2016, we need to create three different DNS records – MIM, PasswordReset and PasswordRegistration. These three records can also be customized for Name and IP Address. So, following the pattern from the last two parts, we have a scrip that will ask for IP Address and names for these records.
The Code
CLS
Write-host "-------------------------------------" -ForegroundColor Green
Write-host " MIM DNS Record Creation Script" -ForegroundColor Green
Write-host "-------------------------------------" -ForegroundColor Green
Write-host ''
Write-host ''
# Import AD Module
Try {Import-Module ActiveDirectory -ErrorAction STOP} Catch {Write-Host "Active Directory Module could not be loaded"}
$DNSRoot = (Get-AdDomain).DNSRoot
# Standard MIM Security Groups
$Records = @("MIM","PasswordReset","PasswordRegistration")
# Loop for all users
Foreach ($Record in $Records) {
# DNS Record
Write-host "Do you want to use the standard DNS record for the $Record ? [s or c] " -ForegroundColor Yellow -NoNewline
$DNSAnswer = Read-Host
If ($DNSAnswer -eq 'c') {
Write-host "What Group name do you want to use instead of $Group ? " -ForegroundColor Yellow -NoNewline
$Alias = Read-Host
$DNSNAme = $Alias+"."+$DNSRoot
} Else {
$DNSName = $Record+"."+$DNSRoot
}
# Get IP Address for Name
Write-Host "Please provide an IP Address for " -ForegroundColor White -NoNewLine
Write-Host "$DNSName : " -ForegroundColor Yellow -NoNewline
$IP = Read-Host
# Create DNS Record
Write-host "Adding DNS records for " -ForegroundColor White -NoNewline
Write-host "$DNSName" -ForegroundColor Green -NoNewline
Write-host " in the $DNSRoot domain." -ForegroundColor White
dnscmd /RecordAdd $DNSRoot $DNSName A $IP
# dnscmd /RecordAdd $ZoneName $ARecordDomainDnsZones A $IP
}
Write-host ' '
Write-host ' '
Write-host '-- Done! ---' -ForegroundColor Yellow
Sample Run-Throughs

Further Reading
The DNSCMD command line tool – DNSCMD
