错误处理 0x800706BA - 找不到 RPC 服务器

Error handling 0x800706BA - RPC-Server not found

我已经编写了一个脚本来从服务器列表中获取操作系统版本。有些服务器不响应“Get-WmiObject”命令。
我想要一个发生此错误的所有主机名的列表。

这为我提供了前几台出现此错误的服务器的列表。
当第一个服务器响应没有错误时,脚本停止。

我希望脚本在服务器未发送错误时不执行任何操作并继续。

有谁知道如何解决这个问题。

提前致谢。

我尝试设置“-ErrorAction continue”但是整个脚本没有 运行。

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
$arraylist_OSInfo = New-Object System.Collections.ArrayList
$file=Get-Content -Path "C:\Temp\PS-Skripte\server2.txt"
foreach ($Hostname in $file)
 {
    try
    {
        Get-WmiObject Win32_OperatingSystem -ComputerName $Hostname -ErrorAction Stop
    }

    catch [Exception]
    {
        if ($_.Exception.GetType().Name -eq "COMException")
        {
          echo "$Hostname - RPC Error" | Out-File -FilePath "C:\temp\PS-Skripte\RPCerror.log" -Append -encoding unicode  
        }
    }
}

我希望从发送错误的所有服务器获得主机名列表:

"Get-WmiObject : Der RPC-Server ist nicht verfügbar. (Ausnahme von HRESULT: 0x800706BA)"

作为 cmdlet 的回答 "Get-WmiObject"

我稍微修改了你的代码

$hostnames = 'NoSuchmachine', 'DoesNotExist'

foreach ($hostname in $hostnames){

try {
  Get-WmiObject -Class win32_operatingsystem  -ComputerName $hostname  -ErrorAction Stop
}
catch {

if ($_.Exception.GetType().Name -eq "COMException") {
   out-file -FilePath c:\test\rpcError.txt -InputObject "$hostname - RPC Error" -Append -Encoding unicode

}
}

}

文件内容为

NoSuchmachine - RPC Error
DoesNotExist - RPC Error

我想你想要的是什么