# Called by the existing provider-update GPO, after its verified installer. [CmdletBinding()] param() $ErrorActionPreference = 'Stop' $computer = Get-CimInstance Win32_ComputerSystem if (-not $computer.PartOfDomain -or $computer.DomainRole -ne 1) { return } $id = '{D789CFD8-5AD4-489F-9B83-7EB5D9D09335}' $provider = Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\$id" -ErrorAction SilentlyContinue $com = Get-Item "HKLM:\SOFTWARE\Classes\CLSID\$id\InprocServer32" -ErrorAction SilentlyContinue $default = (Get-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\System' -Name DefaultCredentialProvider -ErrorAction SilentlyContinue).DefaultCredentialProvider $services = @(Get-Service WinRM,TermService -ErrorAction SilentlyContinue) $ready = $provider -and $provider.GetValue('') -eq 'Acceso Institucional' -and $com -and $com.GetValue('') -and (Test-Path -LiteralPath $com.GetValue('')) -and $default -eq $id -and (Test-Path "$env:ProgramData\SGU\CredentialProvider\settings.json") -and $services.Count -eq 2 -and @($services | Where-Object Status -ne Running).Count -eq 0 $root = Join-Path $env:ProgramData 'LCI-Admin\PolicyConsolidation' $changed = [Collections.Generic.List[string]]::new() function Disable-OwnedTask([string]$Name) { $task = Get-ScheduledTask -TaskPath '\' -TaskName $Name -ErrorAction SilentlyContinue if (-not $task -or -not $task.Settings.Enabled) { return } # Preserve XML and installed files. Never interrupt an installation in flight. if ($task.State -eq 'Running') { Write-Warning "Retirement deferred while $Name runs."; return } if (-not (Test-Path -LiteralPath $root)) { New-Item $root -ItemType Directory -Force | Out-Null } $backup = Join-Path $root ($Name+'.before.xml') if (-not (Test-Path -LiteralPath $backup)) { Export-ScheduledTask -InputObject $task | Set-Content -LiteralPath $backup -Encoding Unicode } Disable-ScheduledTask -InputObject $task | Out-Null $changed.Add($Name) } if ($ready) { # Preserve the enrollment guard until its other features are present. $enrollmentPath = Join-Path $env:ProgramData 'SGU\Enrollment\enrollment.json' $rustDeskReady = $true if (Test-Path -LiteralPath $enrollmentPath) { $enrollment = [IO.File]::ReadAllText($enrollmentPath) | ConvertFrom-Json if ($enrollment.RustDeskServerAddress) { $rustDeskReady = (Get-Service RustDesk -ErrorAction SilentlyContinue).Status -eq 'Running' } } $forwardingReady = Test-Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager' if ($rustDeskReady -and $forwardingReady) { Disable-OwnedTask 'SGU-CredentialProvider-EnrollmentGuard' $guard = Get-ScheduledTask -TaskName 'SGU-CredentialProvider-EnrollmentGuard' -ErrorAction SilentlyContinue if (-not $guard -or -not $guard.Settings.Enabled) { $key = 'HKLM:\SOFTWARE\Policies\LaSalle\ClientMaintenance' if (-not (Test-Path $key)) { New-Item $key -Force | Out-Null } if ((Get-ItemProperty $key -Name ProviderManagedByGpo -ErrorAction SilentlyContinue).ProviderManagedByGpo -ne 1) { New-ItemProperty $key -Name ProviderManagedByGpo -Value 1 -PropertyType DWord -Force | Out-Null } } } } # The global SYSTEMCENTER GPO owns installation/repair from now on. $canonical = Get-ScheduledTask -TaskName 'LCI-ConfigMgr2509-ClientRegistration' -ErrorAction SilentlyContinue if ($canonical -and $canonical.Settings.Enabled -and $canonical.Actions.Arguments -match 'SYSTEMCENTER\.lci\.lasalle\.mx.+Ensure-CMCurrentClient\.ps1') { Disable-OwnedTask 'CED Configuration Manager enrollment' Disable-OwnedTask 'CED Configuration Manager policy enrollment' } if ((Get-Service HealthService -ErrorAction SilentlyContinue).Status -eq 'Running') { Disable-OwnedTask 'LCI-SCOM-AgentInstallNow' } [pscustomobject]@{Computer=$env:COMPUTERNAME;ProviderReady=[bool]$ready;Disabled=@($changed.ToArray())}