Get CimClass - PowerShell


Overview

Get-CimClass retrieves the Common Information Model (CIM) class definitions for the specified namespace or computer system. CIM classes represent managed objects in the Windows Management Instrumentation (WMI) repository. This command allows you to examine the structure and properties of these classes.

Syntax

Get-CimClass [-Namespace <string>] [-ComputerName <string>]
               [[-CimSession <CimSession>] -ResourceUri <string>]
               <CimClassNames[]>

Options/Flags

| Option | Description | Default Value |
|—|—|—|
| -Namespace | Specifies the namespace from which to retrieve the CIMClasses. Defaults to root/cimv2. | root/cimv2 |
| -ComputerName | Specifies the computer system from which to retrieve the CIMClasses. Defaults to the local computer. | Local computer |
| -CimSession | Specifies the CimSession to connect to. | Current CimSession |
| -ResourceUri | Specifies the URI of the resource to retrieve. | N/A |

Examples

Example 1: Get all CIM classes in the root/cimv2 namespace

Get-CimClass

Example 2: Get a specific CIM class by name

Get-CimClass Win32_ComputerSystem

Example 3: Get classes from a remote computer

Get-CimClass -ComputerName remotecomputer.domain.com

Common Issues

  • Access denied: Ensure you have sufficient privileges to access WMI on the target system.
  • Namespace not found: Verify that the specified namespace exists on the target system.
  • Class not found: Check if the specified CIMClass exists in the namespace and computer system.

Integration

Get-CimClass can be used in conjunction with other PowerShell commands to automate WMI tasks. For example:

  • Get-WmiObject: Retrieve WMI objects based on the specified CIM class.
  • Get-CimMethod: Retrieve CIM methods associated with a given CIM class.
  • New-CimInstance: Create new WMI objects based on a CIM class definition.
  • Get-WmiObject
  • Get-CimMethod
  • New-CimInstance