phpwintools/wmi-scripting

A PHP package for using WMI tools.

0.1.1-alpha 2019-09-10 20:05 UTC

README

AppVeyor Build Status Scrutinizer Code Coverage Latest Stable Version Latest Unstable Version License

Current Version: 0.1.1-alpha

This is currently under heavy development and no release candidate has be marked at this point. You are free to use this in production with relatively low-risk as the library itself is fully functional, and is READ-ONLY so there should be no side-effects from its usage.

Documentation (WIP)

Install

composer require phpwintools/wmi-scripting

Basic Usage

Basic usage is to call ::query($connection = null) on an available model from https://github.com/phpwintools/wmi-scripting/tree/master/src/WmiScripting/Models.

PhpWinTools\WmiScripting\Models\LoggedOnUser::query()->get();

This returns a collection of logged on users from the default connection (this is local by configuration). The ModelCollection extends https://github.com/tightenco/collect / Laravel Collections.

You can also instantiate Scripting:

$scripting = new PhpWinTools\WmiScripting\Scripting;
$scripting->addConnection('remote', PhpWinTools\WmiScripting\Connection::simple('server', 'user', 'password'));
$scripting->query('remote')->loggedOnUser()->get();

Whether you use $scripting->query($connection = null)->modelName() or ::query($connection = null) you are dropped into a basic query builder which currently only allows select and where clauses. If there are any subject matter experts who would like to guide me on how this query builder should look please contact me.

Testing

This is still an area that is under development.

You can call Scripting::fake($testCase)->win32Model($class_name); to create a fake for testing without actually creating a real connection to a WMI service.