共用方式為


Get-CimClass

Gets a list of CIM classes in a specific namespace.

語法

ComputerSet (預設值)

Get-CimClass
    [[-ClassName] <string>]
    [[-Namespace] <string>]
    [-Amended]
    [-OperationTimeoutSec <uint>]
    [-ComputerName <string[]>]
    [-MethodName <string>]
    [-PropertyName <string>]
    [-QualifierName <string>]
    [<CommonParameters>]

SessionSet

Get-CimClass
    [[-ClassName] <string>]
    [[-Namespace] <string>]
    -CimSession <CimSession[]>
    [-Amended]
    [-OperationTimeoutSec <uint>]
    [-MethodName <string>]
    [-PropertyName <string>]
    [-QualifierName <string>]
    [<CommonParameters>]

Description

This cmdlet is only available on the Windows platform.

The Get-CimClass cmdlet retrieves a list of CIM classes in a specific namespace. If there is no class name supplied, then the cmdlet returns all the classes in the namespace. Unlike a CIM instance, CIM classes do not contain the CIM session or computer name from which they are retrieved.

範例

Example 1: Get all the class definitions

This example gets all the class definitions under the namespace root/CIMV2.

Get-CimClass

Example 2: Get the classes with a specific name

This example gets the classes that contain the word Disk in their names.

Get-CimClass -ClassName *Disk*

Example 3: Get the classes with a specific method name

This example gets the classes that start with the name Win32 and have a method name that starts with Term.

Get-CimClass -ClassName Win32* -MethodName Term*

Example 4: Get the classes with a specific property name

This example gets the classes that start with the name Win32 and have a property named Handle.

Get-CimClass -ClassName Win32* -PropertyName Handle

Example 5: Get the classes with a specific qualifier name

This example gets the classes that start with the name Win32, contain the word Disk in their names and have the specified qualifier Association.

Get-CimClass -ClassName Win32*Disk* -QualifierName Association

Example 6: Get the class definitions from a specific namespace

This example gets the class definitions that contain the word Net in their names from the specified namespace root/StandardCimv2.

Get-CimClass -Namespace root/StandardCimv2 -ClassName *Net*

Example 7: Get the class definitions from a remote server

This example gets the class definitions that contain the word Disk in their names from the specified remote servers Server01 and Server02.

Get-CimClass -ClassName *Disk* -ComputerName Server01, Server02

Example 8: Get the classes by using a CIM session

$s = New-CimSession -ComputerName Server01, Server02
Get-CimClass -ClassName *Disk* -CimSession $s

This set of commands creates a session with multiple computers and stores it into a variable $s using the New-CimSession cmdlet, and then gets the classes using the Get-CimClass cmdlet.

參數

-Amended

Indicates that objects returned from the CIM query should contain amended information. Typically, amended information is localizable information, such as object and property descriptions that are attached to the CIM object. This is useful for translating numeric values to human-readable values.

This parameter was added in PowerShell 7.3.

參數屬性

類型:SwitchParameter
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-CimSession

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.

參數屬性

類型:

CimSession[]

預設值:None
支援萬用字元:False
不要顯示:False

參數集

SessionSet
Position:Named
必要:True
來自管線的值:True
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-ClassName

Specifies the name of the CIM class for which to perform the operation. You can use tab completion to browse the list of classes, because PowerShell gets a list of classes from the local WMI server to provide a list of class names.

參數屬性

類型:String
預設值:None
支援萬用字元:True
不要顯示:False

參數集

(All)
Position:0
必要:False
來自管線的值:False
來自管線按屬性名稱的值:True
來自剩餘引數的值:False

-ComputerName

Specifies 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.

參數屬性

類型:

String[]

預設值:None
支援萬用字元:False
不要顯示:False
別名:CN, ServerName

參數集

ComputerSet
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:True
來自剩餘引數的值:False

-MethodName

Finds the classes that have a method matching this name. You can use wildcard characters with this parameter.

參數屬性

類型:String
預設值:None
支援萬用字元:True
不要顯示:False

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:True
來自剩餘引數的值:False

-Namespace

Specifies the namespace for CIM operation. The default namespace is root/CIMV2. You can use tab completion to browse the list of namespaces, because PowerShell gets a list of namespaces from the local WMI server to provide the list of namespaces.

參數屬性

類型:String
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:1
必要:False
來自管線的值:False
來自管線按屬性名稱的值:True
來自剩餘引數的值:False

-OperationTimeoutSec

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.

參數屬性

類型:UInt32
預設值:None
支援萬用字元:False
不要顯示:False
別名:OT

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:True
來自剩餘引數的值:False

-PropertyName

Finds the classes which have a property matching this name. You can use wildcard characters with this parameter.

參數屬性

類型:String
預設值:None
支援萬用字元:True
不要顯示:False

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:True
來自剩餘引數的值:False

-QualifierName

Filters the classes by class level qualifier name. You can use wildcard characters with this parameter.

參數屬性

類型:String
預設值:None
支援萬用字元:True
不要顯示:False

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:True
來自剩餘引數的值:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

輸入

None

You can't pipe objects to this cmdlet.

輸出

CimClass

This cmdlet returns a CIM class object.

備註

PowerShell includes the following aliases for Get-CimClass:

  • Windows:
    • gcls

This cmdlet is only available on Windows platforms.