Add one-command server and client bootstraps
This commit is contained in:
@@ -11,8 +11,11 @@ $ErrorActionPreference = 'Stop'
|
||||
$existing = Get-DnsServerResourceRecord -ZoneName $ZoneName -Name $RecordName -RRType A -ErrorAction SilentlyContinue
|
||||
if ($existing) {
|
||||
$current = @($existing.RecordData.IPv4Address.IPAddressToString)
|
||||
if ($current -notcontains $IPv4Address.IPAddressToString) {
|
||||
throw "$RecordName.$ZoneName already exists with a different address: $($current -join ', ')."
|
||||
if ($current.Count -ne 1 -or $current[0] -ne $IPv4Address.IPAddressToString) {
|
||||
# The fixed lab address is an explicit bootstrap input and may change
|
||||
# when the server is rebuilt. Replace only this exact A record set.
|
||||
$existing | Remove-DnsServerResourceRecord -ZoneName $ZoneName -Force
|
||||
Add-DnsServerResourceRecordA -ZoneName $ZoneName -Name $RecordName -IPv4Address $IPv4Address
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user