29 lines
1.4 KiB
PowerShell
29 lines
1.4 KiB
PowerShell
# Local elevated setup for the workgroup administration PC, LCI-77.
|
|
# Domain computers receive the existing CED DNS GPO instead.
|
|
[CmdletBinding()]
|
|
param(
|
|
[string]$InterfaceAlias = 'Wi-Fi',
|
|
[string]$BackupPath = 'C:\Users\alex\Documents\CED-Network-Private\LCI77-Sala-DNS-before.json'
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
if ($env:COMPUTERNAME -ne 'LCI-77') { throw 'This setup is only for LCI-77.' }
|
|
$client = Get-DnsClient -InterfaceAlias $InterfaceAlias
|
|
if (-not (Test-Path -LiteralPath $BackupPath)) {
|
|
$client | Select-Object InterfaceAlias, ConnectionSpecificSuffix |
|
|
ConvertTo-Json | Set-Content -LiteralPath $BackupPath -Encoding UTF8
|
|
}
|
|
Set-DnsClient -InterfaceAlias $InterfaceAlias -ConnectionSpecificSuffix 'lci.lasalle.mx'
|
|
$rules = @(Get-DnsClientNrptRule | Where-Object { $_.Namespace -contains '.lci.lasalle.mx' })
|
|
if ($rules.Count -gt 0 -and ($rules.Count -ne 1 -or $rules[0].NameServers -ne '192.168.54.211')) {
|
|
throw 'An existing domain DNS rule needs review; it was not overwritten.'
|
|
}
|
|
if ($rules.Count -eq 0) {
|
|
Add-DnsClientNrptRule -Namespace '.lci.lasalle.mx' -NameServers '192.168.54.211' -Comment 'CED domain DNS for local administrator Wi-Fi'
|
|
}
|
|
Clear-DnsClientCache
|
|
[pscustomobject]@{
|
|
Computer = $env:COMPUTERNAME
|
|
Suffix = (Get-DnsClient -InterfaceAlias $InterfaceAlias).ConnectionSpecificSuffix
|
|
SI04 = @([Net.Dns]::GetHostAddresses('SI-04') | ForEach-Object IPAddressToString)
|
|
}
|