Get a list of CIM classes in a specific namespace.
Syntax Get-CimClass [[-ClassName] String] [[-Namespace] String] [-MethodName String] [ [-ComputerName String[]] | -CimSession CimSession[] ] [-PropertyName String] [-QualifierName String] [-OperationTimeoutSec UInt32] [CommonParameters] Key -CimSession CimSession[] The CIM session to use for this cmdlet. Enter a variable that contains the CIM session or a command that creates or gets the CIM session, such as the New-CimSession or Get-CimSession cmdlets. For more information, see about_CimSessions. -ClassName String The name of the CIM class for which to perform the operation. NOTE: You can use tab completion to browse the list of classes, because wps_2 gets a list of classes from the local WMI server to provide a list of class names. -ComputerName String[] The computer on which you want to run the CIM operation. You can specify a fully qualified domain name (FQDN), a NetBIOS name, or an IP address. If you specify this parameter, the cmdlet creates a temporary session to the specified computer using the WsMan protocol.If you do not specify this parameter, the cmdlet performs the operation on the local computer using Component Object Model (COM). If multiple operations are being performed on the same computer, using a CIM session gives better performance. -MethodName String Finds the classes that have a method matching this name. You can use wildcard characters with this parameter. -Namespace String Specifies the namespace for CIM operation. The default namespace is root/cimv2. NOTE: You can use tab completion to browse the list of namespaces, because wps_2 gets a list of namespaces from the local WMI server to provide the list of namespaces. -OperationTimeoutSec UInt32 Specifies the amount of time that the cmdlet waits for a response from the computer. By default, the value of this parameter is 0, which means that the cmdlet uses the default timeout value for the server. If the OperationTimeoutSec parameter is set to a value less than the robust connection retry timeout of 3 minutes, network failures that last more than the value of the OperationTimeoutSec parameter are not recoverable, because the operation on the server times out before the client can reconnect. -PropertyName String[] Finds the classes which have a property matching this name. You can use wildcard characters with this parameter. -QualifierName String Filters the classes by class level qualifier name. You can use wildcard characters with this parameter. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer, PipelineVariable -OutVariable.
Standard Alias for Get-CIMClass: gcls
Examples
The CIM classes available will vary according to your operating system.
Get all the class definitions under the namespace root/cimv2:
PS C:\> Get-CimClass
List all the classes involding discs:
PS C:\> Get-cimclass -List | Where cimClassName -like "*disk*"
or
PS C:\> Get-CimClass -ClassName *disk*
Get the classes with a specific method name:
PS> Get-CimClass –ClassName Win32* -MethodName Term*
Get the classes with a specific property name:
PS C:\> Get-CimClass –ClassName Win32* -PropertyName Handle
Get the classes with a specific qualifier name,
get classes that start with the name Win32, contain the word Disk in their names and have the specified qualifier 'Association':
PS C:\> Get-CimClass –ClassName Win32*Disk* -QualifierName Association
Get the class definitions from a specific namespace:
PS C:\> Get-CimClass -Namespace root/standardCimv2 -ClassName *Net*
Get the class definitions from a remote server:
PS C:\> Get-CimClass -ClassName *disk* -ComputerName Server64, Server65
Get the classes by using a CIM session:
PS C:\> $session = New-CimSession -ComputerName Server64, Server65
PS C:\> Get-CimClass -ClassName *disk* -CimSession $session
This set of commands creates a session with multiple computers and stores it into a variable $session using the New-CimSession cmdlet, and then gets the classes using the Get-CimClass cmdlet.
“Money is related to class only in the minds of people who have too much of the former, too little of the latter or none of either” ~ Doug RobarchekRelated PowerShell Cmdlets:
Invoke-CimMethod - Invoke a method of a CIM class or CIM instance.
Get-CimAssociatedInstance - Retrieve CIM instance by an association.
Get-CimInstance - Get a managed resource (storage, network, software etc)
New-CimInstance - Create a new instance of a class.