捕获异常:来源:SWbemLocator RPC服务器不可用

时间:2017-02-01 09:13:51

标签: php wmi

我有wmi脚本我将使用wmi从远程主机获取系统信息某些主机没有打开并抛出

  

捕获异常:来源:SWbemLocator   说明:RPC服务器不可用。
捕获异常:来源:SWbemLocator   描述:RPC服务器不可用

$host = array('192.168.8.1','192.168.8.2','192.168.8.3');

foreach ($host as $ip) {
    $user_name = "username/domain";
    $password = "password";

    try {
        $WbemLocator = new COM ("WbemScripting.SWbemLocator");
        $ss = $WbemLocator->ConnectServer($ip, 'root\\cimv2', $user_name, $password);
        $ss->Security_->ImpersonationLevel = 3;
    } catch(Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }

    $Win32_ComputerSystem    =    $ss->ExecQuery("Select * from Win32_ComputerSystem"); 

    foreach ( $Win32_ComputerSystem as $ComputerSystem ) {
        $System_Name = $ComputerSystem->Name;
        $System_Domain = $ComputerSystem->Domain ;
        $System_SystemType = $ComputerSystem->SystemType;
        $System_Manufacturer = $ComputerSystem->Manufacturer;
        $System_Model = $ComputerSystem->Model;
    }
    echo $System_Name;
}

如果它上面的192.168.8.1主机运行良好但是在循环192.168.8.2中没有运行那么它会给出Caught异常:Source:SWbemLocator 说明:RPC服务器不可用。捕获异常:来源:SWbemLocator 描述:RPC服务器不可用并破坏PHP脚本.. 请帮忙

0 个答案:

没有答案