this is actually a DNS server with TWO(2) different Host A records pointing to TWO(2) different domain names or FQDN but with the same static IP addressYou should have mentioned this in the original post. In this case, I understand why two hostnames are assigned to one IP address. That's ok.
host.com A 10.10.10.10
host.local A 10.10.10.10
Is that okay?
Perhaps a DNS stub zone should have been used for 2 domains instead of creating multiple Host A DNS records with the same IP address?
Clear-Host
$PathToReport = "C:\Temp"
$To = Read-Host "Please enter the email address you wish to send this report to:"
$From = Read-Host "Please enter the sending email address for this report:"
$SMTPServer = Read-Host "Please enter your SMTP server name:"
$ZoneName = Read-Host "Please enter the zone name for which you wish to retrieve static DNS records. This may be your DNS suffix, for instance:"
$DomainController = Read-Host "Enter name of one of your domain controllers that stores DNS records:"
#Get Current date for input into report
$CurrentDate = Get-Date -Format "MMMM, yyyy"
#region Functions
Function Set-AlternatingRows {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,ValueFromPipeline=$True)]
[object[]]$HTMLDocument,
[Parameter(Mandatory=$True)]
[string]$CSSEvenClass,
[Parameter(Mandatory=$True)]
[string]$CSSOddClass
)
Begin {
$ClassName = $CSSEvenClass
}
Process {
[string]$Line = $HTMLDocument
$Line = $Line.Replace("<tr>","<tr $ClassName"">")
If ($ClassName -eq $CSSEvenClass) {
$ClassName = $CSSOddClass
}
Else {
$ClassName = $CSSEvenClass
}
$Line = $Line.Replace("<table>","<table width=""20%"">")
Return $Line
}
}
#endregion
$Header = @"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #D8E4FA;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
.odd { background-color:#ffffff; }
.even { background-color:#dddddd; }
</style>
<title>Static DNS A Records across all Nodes of $ZoneName Domain for $CurrentDate</title>
"@
$Report = Get-DnsServerResourceRecord -ZoneName $ZoneName -ComputerName $DomainController -RRType A | Where-Object Timestamp -eq $Null | Select-Object -Property HostName,RecordType -ExpandProperty RecordData
$NumberOfRecords = $Report | Measure-Object HostName | Select-Object -Property Count
$Report = $Report | Select-Object HostName,RecordType,IPv4Address |
ConvertTo-Html -Head $Header -PreContent "<p><h2>Static DNS A Records across all Nodes of $ZoneName Domain for $CurrentDate</h2></p><br><p><h3>$NumberOfRecords Records listed</h3></p>" |
Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd
$Report | Out-File $PathToReport\Output_AD_GetListStaticARecords.html
Send-MailMessage -To $To -From $From -Subject "Static DNS A Records across all Nodes of $ZoneName Domain for $CurrentDate" -Body ($Report | Out-String) -BodyAsHtml -SmtpServer $SMTPServer
Write-Host "Script completed!" -ForegroundColor Green
Open DHCP console -> right-click the IPv4 -> DNS tab -> make sure that "Allways dynamically update DNS records" and "Discard A and PTR records..." options are checked.