Consolidate laboratory network and client maintenance policies
This commit is contained in:
1 parent
bfa520dec8
commit
5cda541e3d
20 files changed
+534
-107
No files matched your search
@@ -2,10 +2,14 @@
|
||||
param(
|
||||
[string]$TargetOuDn = 'OU=Centro de Experiencia Digital,OU=Laboratorio,DC=lci,DC=lasalle,DC=mx',
|
||||
[string]$GpoName = 'CED - DNS de dominio',
|
||||
[string]$DnsServer = '192.168.54.211',
|
||||
[string[]]$DnsServer = @(),
|
||||
[string]$DomainController = $env:COMPUTERNAME
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
if (-not $DnsServer.Count) {
|
||||
$configuration = [IO.File]::ReadAllText((Join-Path $PSScriptRoot 'ced-network.json')) | ConvertFrom-Json
|
||||
$DnsServer = @($configuration.DnsServers)
|
||||
}
|
||||
Import-Module ActiveDirectory
|
||||
Import-Module GroupPolicy
|
||||
$domain = Get-ADDomain -Server $DomainController
|
||||
@@ -20,7 +24,7 @@ $rule = @($rules | Where-Object { $_.Namespace -contains $namespace })
|
||||
if ($rule.Count -gt 1) { throw 'Duplicate domain DNS policy rules.' }
|
||||
if (-not $rule.Count) {
|
||||
Add-DnsClientNrptRule -GpoName $name -Server $DomainController -Namespace $namespace -NameServers $DnsServer -DisplayName 'CED internal domain DNS' | Out-Null
|
||||
} elseif ($rule[0].NameServers -ne $DnsServer) {
|
||||
} elseif ((@($rule[0].NameServers -split '[;,\s]+' | Where-Object { $_ }) -join ',') -ne ($DnsServer -join ',')) {
|
||||
Set-DnsClientNrptRule -GpoName $name -Server $DomainController -Name $rule[0].Name -NameServers $DnsServer
|
||||
}
|
||||
$link = (Get-GPInheritance -Target $TargetOuDn -Domain $domain.DNSRoot -Server $DomainController).GpoLinks | Where-Object GpoId -eq $gpo.Id
|
||||
|
||||
Reference in new issue
Block a user