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

+10 -23
View File
@@ -4,8 +4,8 @@ param(
[Parameter(Mandatory)][PSCredential]$Credential,
[string]$TargetOuDn = 'OU=Centro de Experiencia Digital,OU=Laboratorio,DC=lci,DC=lasalle,DC=mx',
[string]$DomainController = $env:COMPUTERNAME,
[string]$DnsServer = '192.168.54.211',
[string]$FallbackDnsServer = '192.168.54.1',
[string]$DnsServer = '',
[string]$FallbackDnsServer = '',
[switch]$InstallClient,
[switch]$MigrateWifi,
[switch]$RestartPendingInstall,
@@ -17,13 +17,9 @@ $domain = Get-ADDomain -Server $DomainController
Get-ADOrganizationalUnit -Identity $TargetOuDn -Server $DomainController | Out-Null
$allowed = @(Get-ADComputer -SearchBase $TargetOuDn -Filter 'Enabled -eq $true' -Server $DomainController)
$inventory = Get-Content -LiteralPath $InventoryPath -Raw | ConvertFrom-Json
$source = 'C:\Program Files\Microsoft Configuration Manager\Client\ccmsetup.exe'
if ($InstallClient) {
$signature = Get-AuthenticodeSignature -LiteralPath $source
if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notlike '*Microsoft Corporation*') {
throw 'The Configuration Manager installer is not a valid Microsoft signed binary.'
}
}
$networkConfiguration=[IO.File]::ReadAllText((Join-Path $PSScriptRoot 'ced-network.json'))|ConvertFrom-Json
if(-not $DnsServer){$DnsServer=[string]$networkConfiguration.DnsServers[0]}
if(-not $FallbackDnsServer){$FallbackDnsServer=[string]$networkConfiguration.DnsServers[1]}
$options = New-PSSessionOption -OpenTimeout 10000 -OperationTimeout 180000
foreach ($item in $inventory) {
if ($item.WinRM -eq $false) { continue }
@@ -67,23 +63,14 @@ foreach ($item in $inventory) {
}
if (-not $state.WifiPolicyPresent) { throw 'Native CED Wi-Fi policy was not applied.' }
if ($InstallClient -and -not $state.ClientPresent) {
Copy-Item -LiteralPath $source -Destination C:\ProgramData\LCI-Admin\ccmsetup.exe -ToSession $session
Invoke-Command -Session $session -ArgumentList $ClientSource,[bool]$RestartPendingInstall {
param($clientSource,$restartPending)
if (-not $restartPending -and (Get-Process ccmsetup -ErrorAction SilentlyContinue)) { return }
# Replace a pending installer that was waiting for an inaccessible source.
if (Get-Service ccmsetup -ErrorAction SilentlyContinue) {
Stop-Service ccmsetup -Force -ErrorAction SilentlyContinue
}
# /source alone forces the complete SMB media. Combining it with
# /mp gives MP/DP discovery priority and can leave setup waiting.
$action = New-ScheduledTaskAction -Execute C:\ProgramData\LCI-Admin\ccmsetup.exe -Argument ('/source:"{0}" SMSSITECODE=LCI SMSMP=sgu-dc02.lci.lasalle.mx' -f $clientSource)
Register-ScheduledTask -TaskName 'CED Configuration Manager enrollment' -Action $action -User SYSTEM -RunLevel Highest -Force | Out-Null
Start-ScheduledTask -TaskName 'CED Configuration Manager enrollment'
Invoke-Command -Session $session {
$task=Get-ScheduledTask -TaskName 'LCI-ConfigMgr2509-ClientRegistration' -ErrorAction SilentlyContinue
if(-not $task -or -not $task.Settings.Enabled){throw 'Apply the global SYSTEMCENTER Configuration Manager GPO before requesting client installation.'}
Start-ScheduledTask -InputObject $task
}
}
if ($MigrateWifi) {
foreach ($file in 'Connect-SguCedWifi.ps1','Install-SguCedWifiMaintenance.ps1') {
foreach ($file in 'Install-SguCedWifiMaintenance.ps1','Repair-SguCedWifi.ps1','Set-SguCedClientNetwork.ps1','ced-network.json') {
Copy-Item (Join-Path $PSScriptRoot $file) (Join-Path C:\ProgramData\LCI-Admin $file) -ToSession $session -Force
}
Invoke-Command -Session $session {