Skip to content

Instantly share code, notes, and snippets.

@irwins
Last active Nov 6, 2015
Embed
What would you like to do?
<#
Author: I.C.A. Strachan
Version:
Version History:
Purpose: Pester script to validate that DNS Zones and Records have been configured
#>
[CmdletBinding()]
Param(
[string]$fqdn ='domain.local',
[string[]]$ServerIPAddress= @('192.168.1.4', '192.168.1.5')
)
Import-Module DNSServer -Verbose:$false
Describe "DNS Exchange Configuration Test for $fqdn" {
$zoneNames = @(
"autodiscover.$($fqdn)"
"mail.$($fqdn)"
"webmail.$($fqdn)"
"_autodiscover._tcp.$($fqdn)"
)
Context 'DNS Zones' {
# Test every zone
foreach($zoneName in $zoneNames){
it "Has a zone named: $zoneName" {
Get-DnsServerZone $zoneName | Should Not BeNullOrEmpty
}
}
}
Context 'DNS Resource records' {
foreach ($IPAddress in $ServerIPAddress){
foreach($zoneName in $zoneNames){
It "Has IPAddress $($IPAddress) in zone $($zoneName)"{
(Get-DnsServerResourceRecord -ZoneName $zoneName | out-string) | Should Match $IPAddress
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment