title: Powershell Workflow to reboot computers
body: <p>Code:</p>
  
  <pre><code>workflow Test-RemoteReboot{
      param ([string[]]$serverNames)
      foreach -parallel($server in $serverNames){
          Restart-Computer -PSComputerName $server -Wait -Force
      }
  }
  
  Test-RemoteReboot SP,SP2
  </code></pre>
  
  <p>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):</p>
  
  <blockquote>
    <p>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]</p>
  </blockquote>
  
  <p>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:</p>
  
  <pre><code>workflow Test-LocalRebootRemotely{
  param ([string[]]$serverNames)
      foreach -parallel($server in $serverNames){
          InlineScript { Restart-Computer -Force } -PSComputerName $server
      }
  }
  
  Test-LocalRebootRemotely SP,SP2
  </code></pre>
  
  <p>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?</p>