January 30th, 2014

PowerTip: Use PowerShell to Retrieve CIM Methods

Doctor Scripto
Scripter

Summary: Learn how to use Windows PowerShell to retrieve CIM methods. Hey, Scripting Guy! Question How can I use Windows PowerShell to dynamically obtain a list of CIM methods?

Hey, Scripting Guy! Answer Use the following script:

Clear-Host;  

$ClassList = Get-CimClass;  

foreach ($CimClass in $ClassList) {

    foreach ($CimMethod in $CimClass.CimClassMethods) {

        $Method = [PSCustomObject]@{

            Class = $CimClass.CimClassName;

            MethodName = $CimMethod.Name;

            Static = $false;

        };

        if ($CimMethod.Qualifiers.Name -contains ‘static’) {

            $Method.Static = $true;

        };

        $Method;

    }

}

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.