PHP Classes
elePHPant
Icontem

File: usage.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Zsolt Munoz  >  Base WMI  >  usage.php  >  Download  
File: usage.php
Role: Example script
Content type: text/plain
Description: Usage File
Class: Base WMI
Manage Windows resources with WMI objects
Author: By
Last change:
Date: 3 years ago
Size: 2,454 bytes
 

Contents

Class file image Download
<?php
   
/**
     * Usage Document for BaseWMI
     * Includes documentation for SMS/SCCM & WMI
     * Each Snippet of Code will work on its own but cannot run entire script below
     */
   
   
    /**********************SNIPPET**********************/
   
require_once("namespace.wmi.php");
   
    use \
WMI\WMLQuery as SimpleWML;
   
   
// Basic Usage of the SimpleWML
   
$SimpleWML = new SimpleWML('hostname','adminaccount','adminpassword','\root\CIMV2');
   
$SimpleWML->setWMIClass('Win32_BIOS');
   
$SimpleWML->setSelection('*');
   
$SimpleWML->setWhere('Manufacturer = "Dell Inc."');
   
$SimpleWML->select();
   
   
var_dump($SimpleWML->recordSet());
   
   
/**********************SNIPPET**********************/
   
require_once("namespace.wmi.php");
   
    use \
WMI\ObjQuery as SimpleWMI;
   
   
$SimpleWMI = new SimpleWMI('hostname','adminaccount','adminpassword','\root\CIMV2');
   
$objStartup = $SimpleWMI->setWMIClass('Win32_ProcessStartup');
   
$objConfig = $objStartup->SpawnInstance_;
   
$objConfig.ShowWindow = SW_NORMAL;
   
   
$objWin32Proc = $SimpleWMI->setWMIClass('Win32_Process');
   
$intWin32Proc = $objWin32Proc->Create("Notepad.exe", NULL, $objConfig, $intProcessID);
    if(
$intWin32Proc != 0) {
        echo
"Process could not be created.\n";
        echo
"Command: Notepad.exe\n";
        echo
"Return Value: " . $intWin32Proc;
    } else {
        echo
"Command: Notepad.exe\n";
        echo
"Process ID: " . $intProcessID;
    }
   
   
/**********************SNIPPET**********************/
   
require_once("namespace.wmi.php");
    require_once(
"CIMV2\SimpleCIMV2.php");
   
    use \
WMI\CIMV2\SimpleCIMV2 as SimpleCIMV2;
   
   
$SimpleCIMV2 = SimpleCIMV2::Connect('hostname','adminaccount','adminpassword');
   
   
var_dump($SimpleCIMV2->CIMV2Query('Win32_BIOS',array('Manufacturer'=>'Dell Inc.')));
   
var_dump($SimpleCIMV2->CIMV2ExposeMethods('Win32_Process'));
   
   
/**********************SNIPPET**********************/
   
require_once("namespace.wmi.php");
    require_once(
"SMS\SimpleSMS.php");
   
    use \
WMI\SMS\SimpleSMS as SimpleSMS;
   
   
$SimpleSMS = SimpleSMS::Connect('sccmserver','adminaccount','adminpassword','SM1');
   
$SimpleSMS->OmitFields('CollectionID','COLLROOT');
   
$SimpleSMS->OmitFields('Name','tst%');
   
$SimpleSMS->OmitFields('Name','sms%');
   
$SimpleSMS->OmitFields('Name','Uninstall%');
   
$SimpleSMS->OmitFields('CollectionID','SMS%');
   
$SimpleSMS->OmitFields('Comment','%HID%');
   
$arrSimpleSMS = $SimpleSMS->GetCollectionDetailsByName('Microsoft');
   
   
var_dump($arrSimpleSMS);
?>