Back to Blog

    SharePoint

    Patching SharePoint Server SE: when remote updates hang

    Our CU update of a four-server SharePoint Server SE farm: why the install hung over WinRM, what fixed it, and where a coding agent should help.

    February 2, 20267 min read
    Marcel Haas

    Marcel Haas

    Solution Architect, CEO

    marcel.haas@cnext.ch
    CNEXT AI Agent
    In this article

    You install a cumulative update (CU) for SharePoint Server Subscription Edition in two steps: first the update packages on every server in the farm, then the build-to-build upgrade with PSConfig. When we updated a four-server farm, the remote installation over WinRM hung; we solved it with scheduled tasks running as SYSTEM and, on the server without WinRM access, with CIM. A coding agent (GitHub Copilot in VS Code) helped with the inventory, the script and the diagnosis; approval stays with the administrators.

    The farm and the update

    Our starting point was a four-server MinRole farm:

    ServerMinRolePurpose
    SP-SRV-01SearchCrawl and index components
    SP-SRV-02ApplicationCentral Administration, farm timer jobs
    SP-SRV-03DistributedCacheDistributed cache
    SP-SRV-04WebFrontEndUser requests

    Behind it are two SQL instances (SQL-SRV-01\SQL-INST-01 and SQL-SRV-02\SQL-INST-02) with around 61 databases for 8 web applications. The update took the farm from build 16.0.18526.20508 (KB5002768, July 2025) to build 16.0.19127.20442 (KB5002822, January 2026). We worked on SP-SRV-02, the application server, where VS Code ran with GitHub Copilot.

    What Microsoft prescribes

    Microsoft describes two phases: first the required update packages are installed on the SharePoint servers, then the build-to-build upgrade follows with the Configuration Wizard or PSConfig. Depending on the update, a language-independent and a language-dependent package may be needed. Microsoft does not prescribe a fixed installation order within the farm; the maintenance plan depends on topology and services.

    Step 1: inventory before the script

    Before the agent wrote a single line of script, it took an inventory of the farm:

    powershell.exe -NoProfile -Command "
        Add-PSSnapin Microsoft.SharePoint.PowerShell
        Get-SPFarm | Select-Object Name, BuildVersion
        Get-SPServer | Where-Object { $_.Role -ne 'Invalid' } |
            Select-Object Name, Role, Status | Format-Table -AutoSize
    "

    From the result it derived a patch order for this farm (Search, DistributedCache, Application, WebFrontEnd), identified the SQL instances, content databases and web applications, and wrote an upgrade report. Only then did it create the script. That was where the real value lay: not a generic script, but one for the actual topology.

    Step 2: a script in six phases

    The agent produced a PowerShell script of around 850 lines (Install-SPSE-January2026CU.ps1):

    PhasePurpose
    0 – Pre-flightValidate the build, check WinRM, verify disk space, confirm backups
    1 – DownloadDownload KB5002822 from the Microsoft Update Catalog
    2 – DistributeCopy the 1.6 GB package to all four servers via UNC
    3 – Pause searchSuspend-SPEnterpriseSearchServiceApplication
    4 – InstallInstall the packages and run PSConfig per server
    5 – Post-patchVerify the build, upgrade the databases, resume search, clear the configuration cache

    Problem 1: Start-Process hangs in the WinRM session

    In phase 4 the script was to install the package on the first remote server (SP-SRV-01). This call hung indefinitely:

    Invoke-Command -ComputerName "SP-SRV-01" -ScriptBlock {
        Start-Process -FilePath "C:\SPPatches\uber-subscription-kb5002822-fullfile-x64-glb.exe" `
            -ArgumentList "/quiet /norestart" -Wait
    }

    The agent's diagnosis, based on the behaviour: a process started over WinRM (Invoke-Command) runs in session 0, the non-interactive session for services. Start-Process -Wait waits for the process to exit cleanly. Over WinRM, however, large MSI and EXE installers often spawn child processes that outlive the parent, or wait for interactive session handles that never arrive.

    The solution was Windows scheduled tasks. The agent rewrote the remote installation so that a task runs as SYSTEM in its own session, independent of WinRM:

    Invoke-Command -ComputerName $ServerName -ScriptBlock {
        param([string]$ExePath, [int]$TimeoutMin, [string]$TaskName)
        Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false -ErrorAction SilentlyContinue
        $action   = New-ScheduledTaskAction -Execute $ExePath -Argument "/quiet /norestart"
        $settings = New-ScheduledTaskSettingsSet `
            -ExecutionTimeLimit (New-TimeSpan -Minutes $TimeoutMin)
        Register-ScheduledTask -TaskName $TaskName -Action $action `
            -Settings $settings -User "SYSTEM" -RunLevel Highest -Force | Out-Null
        Start-ScheduledTask -TaskName $TaskName
        # Polling every 20 seconds...
    } -ArgumentList $patchExe, $timeoutMin, $taskName

    The task runs as SYSTEM with RunLevel Highest, so it has full administrator rights and none of the restrictions of the WinRM session. The WinRM session only polls the task's status.

    Problem 2: the local server refuses WinRM

    Three of the four servers accepted WinRM connections. SP-SRV-02, the local application server, refused them. A local Start-Process, Invoke-Command -ComputerName localhost and a local schtasks failed as well. What worked was creating the process through CIM/WMI:

    Invoke-CimMethod -ComputerName "SP-SRV-02" `
        -ClassName Win32_Process `
        -MethodName Create `
        -Arguments @{
            CommandLine = "C:\SPPatches\KB5002822\uber-subscription-kb5002822-fullfile-x64-glb.exe /quiet /norestart"
        }

    Our explanation: the operator account had DCOM activation rights on SP-SRV-02 through Group Policy, but no WinRM access. CIM over DCOM uses the RPC Endpoint Mapper (port 135 plus dynamic ports) rather than the WinRM ports 5985/5986: a different protocol with different permissions.

    Step 3: install the packages in parallel

    At first the installation ran server by server. The packages, however, update the files on each server; the databases are only upgraded by PSConfig. So the agent started the installation on all four servers at the same time:

    • three times via a scheduled task, on the servers with WinRM access
    • once via CIM/WMI Win32_Process.Create, on the local server

    Installing the 1.6 GB CU typically takes 30–40 minutes per server. In this run the application server needed around two hours, which made it the slowest. In parallel, the whole installation took about as long as on that server; one after the other, we estimate it would have taken around four hours.

    Step 4: monitor with CIM

    Four parallel installations need monitoring that works on every server. CIM was the common basis:

    $servers = @('SP-SRV-01','SP-SRV-02','SP-SRV-03','SP-SRV-04')
    foreach ($srv in $servers) {
        $procs = Get-CimInstance -ComputerName $srv -ClassName Win32_Process `
            -Filter "Name LIKE '%uber%' OR Name='msiexec.exe'"
        if ($procs) {
            foreach ($p in $procs) { Write-Host "  PID=$($p.ProcessId) Name=$($p.Name)" }
        } else {
            Write-Host "  No installer processes found"
        }
    }

    Step 5: PSConfig server by server

    After the packages comes the build-to-build upgrade. The agent generated this PSConfig call for it:

    psconfig.exe -cmd setup -cmd upgrade -inplace b2b -wait -force -cmd applicationcontent -install -cmd installfeatures

    PSConfig ran first on SP-SRV-02, the application server hosting Central Administration. The agent followed the progress and, once it had finished, ran the same sequence on SP-SRV-01, SP-SRV-03 and SP-SRV-04. PSConfig completed without errors, the databases were upgraded to build 16.0.19127.20442, and the farm's health was checked at the end of the session.

    What we take away

    These three techniques help whether or not you use an AI agent:

    1. 1Start remote installations as a scheduled task. Start-Process -Wait in a WinRM session can hang with large installers. A task running as SYSTEM, whose status the session only polls, avoids this.
    2. 2Use CIM as a way out when WinRM is blocked. A different protocol with different permissions.
    3. 3Packages in parallel, PSConfig in sequence. In our run, first on the application server hosting Central Administration, then on the other servers.

    Where a coding agent should help

    In this session the agent was useful for the inventory, the script and troubleshooting: it adapted the script to the real topology and found a way around both remoting problems. An agent should not approve a production patch run by itself, though. Useful tasks are:

    • comparing Microsoft's current update list with the inventoried farm version;
    • drafting pre-checks, backups, a maintenance window and post-update checks;
    • running commands in a test system and summarising the logs for a person.

    A qualified person approves the package choice, permissions, scripts and their effects. Test with a copy of production data, verify recovery and define an abort plan. After the update, administrators check the farm's health, its services and the core business functions.

    Limits

    • We describe one run on one farm with one CU. Duration and behaviour depend on hardware, topology and the update.
    • The order Search, DistributedCache, Application, WebFrontEnd was our plan for this farm, not a Microsoft requirement.
    • The code samples come from the session in VS Code with GitHub Copilot. Adapt server names, paths and timeouts to your environment.

    Sources

    SharePointGitHub CopilotWorkflowsSchweiz
    Teilen:

    AI tools may have supported the creation of this article. CNEXT is responsible for the published content. Product features and prices can change; check the linked primary sources for current details.

    Marcel Haas

    Marcel Haas

    Solution Architect, CEO

    6x Microsoft Applied Skills

    Discuss a SharePoint Server update

    We discuss the maintenance plan, testing and sequence for your farm's next update with you.