The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

本文介绍了解决在使用PowerShell通过WMI远程重启计算机时出现的“The RPC server is unavailable”错误的方法。主要包括检查防火墙设置、验证主机名或IP地址、确保相关服务已启动等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在用powershell运行脚本调用WMI远程启动机器的时候碰到的:

 

"The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)" error may occurs when deploying VNC to a remote computer or when using built-in management tools.
There can be a few reasons for this error:

The remote computer is blocked by the firewall.
Solution: Open the Group Policy Object Editor snap-in (gpedit.msc) to edit the Group Policy object (GPO) that is used to manage Windows Firewall settings in your organization. Open Computer Configuration, open Administrative Templates, open Network, open Network Connections, open Windows Firewall, and then open either Domain Profile or Standard Profile, depending on which profile you want to configure. Enable the following exception: "Allow Remote Administration Exception" and "Allow File and Printer Sharing Exception".
Host name or IP address is wrong or the remote computer is shutdown.
Solution: Verify correct host name or IP address.
The "TCP/IP NetBIOS Helper" service isn't running.
Solution: Verity that "TCP/IP NetBIOS Helper" is running and set to auto start after restart.
The "Remote Procedure Call (RPC)" service is not running on the remote computer.
Solution: Verity that "Remote Procedure Call (RPC)" is running and set to auto start after restart.
The "Windows Management Instrumentation" service is not running on the remote computer.
Solution: Verity that "Windows Management Instrumentation" is running and set to auto start after restart.

 

第一个解决方法基本可以解决问题的。下面是调用WMI远程重启机器的脚本

# Define input parameters
param (
  [string] $filename = $(throw "Filename is required!")
)

Write-Host "Reading computer names from $filename"

# Read file
$computers = get-content $filename

write-Host "Restarting computers:"$computers

foreach ($computer in $computers) 
{

  # Connect to WMI
  $wmi = get-wmiobject -class "Win32_OperatingSystem" `
  -namespace "root\cimv2" -computer $computer

  # Add privileges
  #$wmi.psbase.Scope.Options.EnablePrivileges = $true


  # Restart computer
  foreach ($item in $wmi) {
    $wmi.reboot()
    write-host "Restarted " + $computer
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值