Configure CED Wi-Fi policy and scoped management enrollment

This commit is contained in:
alexrg committed 2026-10-01 10:16:24 -06:00
1 parent b07dbe17d0
commit 46c0be732a
14 files changed
+921 -6

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
[CmdletBinding()]
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]$DomainController = $env:COMPUTERNAME
)
$ErrorActionPreference = 'Stop'
Import-Module ActiveDirectory
Import-Module GroupPolicy
$domain = Get-ADDomain -Server $DomainController
Get-ADOrganizationalUnit -Identity $TargetOuDn -Server $DomainController | Out-Null
$gpo = Get-GPO -Name $GpoName -Domain $domain.DNSRoot -Server $DomainController -ErrorAction SilentlyContinue
if (-not $gpo) { $gpo = New-GPO -Name $GpoName -Domain $domain.DNSRoot -Server $DomainController }
if ($gpo.GpoStatus -ne 'UserSettingsDisabled') { $gpo.GpoStatus = [Microsoft.GroupPolicy.GpoStatus]::UserSettingsDisabled }
$name = $domain.DNSRoot+'\'+$GpoName
$namespace = '.'+$domain.DNSRoot
$rules = @(Get-DnsClientNrptRule -GpoName $name -Server $DomainController)
$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) {
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
if (-not $link) { New-GPLink -Guid $gpo.Id -Target $TargetOuDn -Domain $domain.DNSRoot -Server $DomainController -LinkEnabled Yes | Out-Null }
elseif (-not $link.Enabled) { Set-GPLink -Guid $gpo.Id -Target $TargetOuDn -Domain $domain.DNSRoot -Server $DomainController -LinkEnabled Yes | Out-Null }
[pscustomobject]@{Gpo=$GpoName;TargetOu=$TargetOuDn;Namespace=$namespace;NameServers=$DnsServer}