WSMan::WSBasic Examples
This section shows a few code examples for
WSMan::WSBasic
.
Using Enumeration Modes
To use one of the enumeration modes like
EnumerateEPR
or
EnumerateEPRandObject
, call the
Enumerate operation with
EnumerationMode
enabled. You can also specify the
enumeration mode in the constructor.
$result = $client->Enumerate(class_name => 'CIM_Processor', #namespace => 'root/cimv2', #if needed. enummode => 'EnumerateEPR' );
Registering Classes
To perform operations on vendor-specific classes, you must register them first with the client. The actual URL depends on your WS-Management software.
$client->register_class_ns(Linux => 'http://www.dmtf.org/linux');
Using Enumerate and Pull Operations
#!/usr/bin/perl -w use strict; use WSMan::WSBasic; #Import the module. my ($enumid, result, $client); #declaring variables. #Construct the client. $client = WSMan::WSBasic->new( path => 'wsman', username => 'wsman', password => 'secret', port => '8889', address => 'http://something.somewhere.com' ); #Execute the Enumerate method. $result = $client->Enumerate(class_name => 'CIM_Processor', #namespace => 'root/cimv2' ); if($result->fault){ #If a fault occurred, then print the faultstring die $result->faultstring; } else{ #If no fault occurred then get the enumid. $enumid = $result->result; } $result = $client->PullRelease( class_name => 'CIM_Processor', enumid => $enumid, action => 'Pull', #namespace => 'root/cimv2' ); if($result->fault){ #If a fault occurred, then print the faultstring die $result->faultstring; } else{ # Do stuff with $result, which is a SOAP::SOM object containing a deserialized XML reply. # It is better to use the Generic Operations module, built on top of this module. }