2

Code:

workflow Test-RemoteReboot{
    param ([string[]]$serverNames)
    foreach -parallel($server in $serverNames){
        Restart-Computer -PSComputerName $server -Wait -Force
    }
}

Test-RemoteReboot SP,SP2

Issue: this is a small excerpt from a pretty long workflow I built in powershell. By all accounts, this should work but I get the following error (even when running this script in isolation):

Microsoft.PowerShell.Utility\Write-Error : The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The computer SP2 is skipped. Fail to retrieve its LastBootUpTime via the WMI service with the following error message: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA). At line:433 char:25 + ... Receive-Job -Job $job -Wait -Verbose -Debug -ErrorAction ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], ActionPreferenceStopException + FullyQualifiedErrorId : System.Management.Automation.ActionPreferenceStopException,Microsoft.PowerShell.Commands.WriteErrorCommand + PSComputerName : [localhost]

I looked into the RPC server unavailable issue. Firewall is down, RPC Service is running, Servers are on domain, Workflow running from domain member computer, as domain admin. I can successfully PSRemote into the machines and do whatever. I can even do this:

workflow Test-LocalRebootRemotely{
param ([string[]]$serverNames)
    foreach -parallel($server in $serverNames){
        InlineScript { Restart-Computer -Force } -PSComputerName $server
    }
}

Test-LocalRebootRemotely SP,SP2

The problem is, is that I need a return value to determine if I need to reboot and handle other logic outside of the remote computer. I do notice that there is an abnormal pause just before it errors. So maybe it is a timeout? anyone have a similar issue?

1 Answer 1

6

You can try the Restart-Computer cmdlet with the -Protocol WSMan parameter instead of the default DCOM over RPC protocol (-Protocol DCOM).

This would confirm that your RPC network packets are blocked somewhere.

2
  • The default help page for Restart-Computer shows version 7 which do not have this property any more. You have to look at version 5.1 for it.
    – Stoinov
    Apr 17, 2020 at 14:50
  • @Stoinov Yes PowerShell 7 doesn't use DCOM anymore. Thus, if it's a firewall issue, you can't run any remote cmdlet.
    – Luke
    Apr 18, 2020 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.