I'm using the Test-PendingReboot function to inspect registry-based reboot status on Windows servers. Running it against an individual server works, but running it in a foreach loop over enabled computer accounts produces RPC errors. I also paused the security agents and saw the same behavior. The script worked against all of these servers last year. The computer list is built from Active Directory, and currently uses Select-Object Name before passing each result to Test-PendingReboot. What should I check or change?
3 Answers
An RPC error usually means the remote connectivity path is failing, not necessarily that the security software is blocking it. Check that the Remote Registry service is available if the module requires it, and verify that the firewall permits RPC endpoint mapping and the required dynamic RPC ports between the management machine and the servers. DNS resolution and server availability are worth checking too.
If the environment crosses domains or uses different credentials, investigate Kerberos and delegation as well. RPC failures can appear when the first hop authenticates successfully but the remote operation needs another authentication hop. Capture the full exception and identify which computer fails first; that will help separate a code issue from a firewall, DNS, permissions, or authentication problem.
The module can accept an array of computer names, so you may not need the loop at all. Also, Select-Object Name returns objects with a Name property rather than plain strings. Try extracting the names explicitly and pass the resulting string array to the function: `$computers = Get-ADComputer -Filter 'OperatingSystem -like "*Windows Server*"' | Where-Object Enabled | Sort-Object Name | Select-Object -ExpandProperty Name` followed by `Test-PendingReboot -ComputerName $computers -Detailed -SkipConfigurationManagerClientCheck`. If you keep the loop, use `$computer.Name` or `Select-Object -ExpandProperty Name`.
That object-versus-string issue is easy to miss. I’d also test one item from the exact generated array first, then test a small batch to determine whether the failure is tied to a particular server or to the loop itself.

If the same host works individually, compare the exact name being passed in each case. A returned AD object, an FQDN, a stale computer account, or a server that is offline can make the batch look like a general RPC problem.