#!/usr/bin/php -q 5) { // if the number of arguments isnt above 5 then don't bother with the where = etc $condition_key = $argv[5]; $condition_val = escapeshellarg($argv[6]); } else { $condition_key = null; }; // globals $wmiexe = '/usr/local/bin/wmic'; // executable for the wmic command $output = null; // by default the output is null $inc = null; $sep = " "; $wmiquery = 'SELECT '.$columns.' FROM '.$wmiclass; // basic query built if ($condition_key != null) { $wmiquery = $wmiquery.' WHERE '.$condition_key.'='.$condition_val; // if the query has a filter argument add it in }; $wmiquery = '"'.$wmiquery.'"'; // encapsulate the query in " " $wmiexec = $wmiexe.' -U '.$user.'%'.$pass.' //'.$host.' '.$wmiquery; // setup the query to be run if ($dbug == true) { echo "\n\n".$wmiexec."\n\n"; // debug :) $sep = "\n"; }; exec($wmiexec,$wmiout); // execute the query if(strstr($wmiout[0],'ERROR') != false) { exit; }; if (count($wmiout) > 0) { $names = explode('|',$wmiout[1]); // build the names list to dymanically output it for($i=2;$i 3 ) { $inc = $i-2; }; // if there are multiple rows returned add an incremental number to the returned keyname $output = $output.$names[$j++].$inc.':'.str_replace(':','',$item).$sep; }; }; }; echo $output; ?>