Consolidate laboratory network and client maintenance policies

This commit is contained in:
alexrg committed 2026-10-14 21:49:32 -06:00
1 parent bfa520dec8
commit 5cda541e3d
20 files changed
+534 -107

No files matched your search

+1 -14
View File
@@ -88,20 +88,7 @@ if($requested){
$rolledBack=$true
}
}else{$state=$before}
foreach($r in $state){
$adapter=Get-NetAdapter|Where-Object{[guid]$_.InterfaceGuid -eq [guid]$r.Interface}
if(-not $adapter -or -not $r.Ssid){continue}
if($r.Ssid -eq 'Centro de Experiencia Digital'){
$desired=@('192.168.54.211','192.168.54.1')
$actual=@((Get-DnsClientServerAddress -InterfaceIndex $adapter.ifIndex -AddressFamily IPv4).ServerAddresses)
if(($actual -join ',') -ne ($desired -join ',')){Set-DnsClientServerAddress -InterfaceIndex $adapter.ifIndex -ServerAddresses $desired}
}else{
# Emergency Wi-Fi must obtain its own DNS; the internal domain NRPT stays intact.
$localKey='HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\'+([guid]$adapter.InterfaceGuid).ToString('B')
$manual=(Get-ItemProperty -LiteralPath $localKey -Name NameServer -ErrorAction SilentlyContinue).NameServer
if($manual){Set-DnsClientServerAddress -InterfaceIndex $adapter.ifIndex -ResetServerAddresses}
}
}
$network=& (Join-Path $PSScriptRoot 'Set-SguCedClientNetwork.ps1') -ConnectedInterface @($state.Interface) -ConnectedSsid @($state.Ssid)
if($requested -and -not $rolledBack){Register-DnsClient -ErrorAction SilentlyContinue}
$result=[pscustomobject]@{Utc=[DateTime]::UtcNow.ToString('o');Computer=[string]$env:COMPUTERNAME;Identity=[string][Security.Principal.WindowsIdentity]::GetCurrent().Name;UserSessions=[Sgu.CedMachineWifi]::UserSessions();MachineProfileReady=(@($state|Where-Object MachineProfileReady).Count -gt 0);ConnectedToCed=($state.Ssid -contains 'Centro de Experiencia Digital');RolledBack=$rolledBack;Interfaces=@($state|Select-Object Interface,Ssid,Profile,MachineProfileReady,GroupProfileRepaired,MachineProfileCreated,OtherProfilesMadeManual,ConnectionRequested,QueryError);PeriodicPolling=$false}
if(Test-Path -LiteralPath $destination){$result|ConvertTo-Json -Depth 5|Set-Content -LiteralPath(Join-Path $destination 'machine-wifi-status.json') -Encoding UTF8}