Bug #74994 [Opn->Nab]: COM Win32_PingStatus error
| From: | requinix@php.net | Date: | Thu, 27 Jul 2017 08:39:41 +0000 |
| Subject: | Bug #74994 [Opn->Nab]: COM Win32_PingStatus error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210365@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74994&edit=1
ID: 74994
Updated by: requinix@php.net
Reported by: benjamin dot versini at gmail dot com
Summary: COM Win32_PingStatus error
-Status: Open
+Status: Not a bug
Type: Bug
Package: COM related
Operating System: Windows 2016 Standard
PHP Version: 7.1.7
Block user comment: N
Private report: N
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
I can tell you right now that $srv needs quotes in the query and $pings will be a collection. Check
that your PHP code correctly matches up with your PowerShell commands.
Previous Comments:
------------------------------------------------------------------------
[2017-07-27 08:16:08] benjamin dot versini at gmail dot com
Description:
------------
Hi,
I use the COM object of PHP to access to WMI Win32_PingStatus for create a remote ping. It's
impossible to obtain the result of my request:
My Error:
com_exception
Unable to lookup `statuscode': Unknown Name.
Test script:
---------------
My Class:
class Windows
{
protected $servers;
protected $username;
protected $password;
public function __construct($servers, $username, $password)
{
$this->servers = $servers;
$this->username = $username;
$this->password = $password;
}
protected function services($command)
{
$services = (new \COM
("WbemScripting.SWbemLocator"))->ConnectServer($this->servers, $command,
$this->username, $this->password);
$services->Security_->AuthenticationLevel = 3;
$services->Security_->ImpersonationLevel = 3;
return $services;
}
public function getHosts()
{
return $this->services('root\\cimv2')
->ExecQuery('Select * from Win32_ComputerSystem');
}
public function GetPing($srv)
{
var_dump($srv);
return $this->services('root\\cimv2')
->ExecQuery('select * from Win32_Pingstatus where
Address='.$srv.'');
}
}
And my View:
$servername = '10.54.1.5';
$vmadress = new \Windows($servername, 'Ceicom-Cloud\Administrateur',
'Ceicom3333');
$pings = $vmadress->getPing('10.16.0.1');
foreach ($pings->statuscode as $ping)
var_dump($ping);
I have tested my class with my function getHosts and it's Ok !
Expected result:
----------------
If i user the PowerShell for Win32_PingStatus (With the same code) i have the return of
statuscode...
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74994&edit=1