-
-
Save irwins/3831f3c6b6825598ac28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
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