Jump to content

PHP and WMI - querying for IP addresses on remote hosts


ryamigo

Recommended Posts

Hello,

 

I'm attempting to write a PHP script to query WMI for an IP address of a host. The reason I'm doing this instead of getbyhostname is because NAT translations on the network can cause inaccurate results. The question is two-fold:

 

1) My Script is as follows

<?

$obj = new COM ( 'winmgmts://localhost/root/CIMV2' );
$wmi_network = $obj->ExecQuery("Select * From Win32_NetworkAdapterConfiguration");

foreach ( $wmi_network as $wmi_call )
{
    $ipaddr = $wmi_call->IPAddress;
    echo $ipaddr;
}
?>

 

I get the following error when running the script:

Catchable fatal error: Object of class variant could not be converted to string

 

 

2) How do I go about querying a remote host on the network with valid credentials?

 

 

Thank you

you can't do it with PHP, it is run purely server side, you would need javascript or possably ajax. 

 

Although I can't think of a single legal reason you could have to be trying to obtain this information without simply enquiering from the person using the computer that you want the local IP address of.

 

P.S. Bumping posts is against the rules.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.