php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74994 COM Win32_PingStatus error
Submitted: 2017-07-27 08:16 UTC Modified: 2017-07-27 08:39 UTC
From: benjamin dot versini at gmail dot com Assigned:
Status: Not a bug Package: COM related
PHP Version: 7.1.7 OS: Windows 2016 Standard
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: benjamin dot versini at gmail dot com
New email:
PHP Version: OS:

 

 [2017-07-27 08:16 UTC] 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...


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-27 08:39 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2017-07-27 08:39 UTC] requinix@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 15:01:28 2024 UTC