Invoke-CimMethod

Windows Server 2012 R2 and Windows 8.1

Invoke-CimMethod

Invokes a method of a CIM class.

구문

Parameter Set: ClassNameComputerSet
Invoke-CimMethod [-ClassName] <String> [[-Arguments] <IDictionary> ] [-MethodName] <String> [-ComputerName <String[]> ] [-Namespace <String> ] [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: CimClassComputerSet
Invoke-CimMethod [-CimClass] <CimClass> [[-Arguments] <IDictionary> ] [-MethodName] <String> [-ComputerName <String[]> ] [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: CimClassSessionSet
Invoke-CimMethod [-CimClass] <CimClass> [[-Arguments] <IDictionary> ] [-MethodName] <String> -CimSession <CimSession[]> [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: CimInstanceComputerSet
Invoke-CimMethod [-InputObject] <CimInstance> [[-Arguments] <IDictionary> ] [-MethodName] <String> [-ComputerName <String[]> ] [-OperationTimeoutSec <UInt32> ] [-ResourceUri <Uri> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: CimInstanceSessionSet
Invoke-CimMethod [-InputObject] <CimInstance> [[-Arguments] <IDictionary> ] [-MethodName] <String> -CimSession <CimSession[]> [-OperationTimeoutSec <UInt32> ] [-ResourceUri <Uri> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: ClassNameSessionSet
Invoke-CimMethod [-ClassName] <String> [[-Arguments] <IDictionary> ] [-MethodName] <String> -CimSession <CimSession[]> [-Namespace <String> ] [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: QueryComputerSet
Invoke-CimMethod [[-Arguments] <IDictionary> ] [-MethodName] <String> -Query <String> [-ComputerName <String[]> ] [-Namespace <String> ] [-OperationTimeoutSec <UInt32> ] [-QueryDialect <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: QuerySessionSet
Invoke-CimMethod [[-Arguments] <IDictionary> ] [-MethodName] <String> -CimSession <CimSession[]> -Query <String> [-Namespace <String> ] [-OperationTimeoutSec <UInt32> ] [-QueryDialect <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: ResourceUriComputerSet
Invoke-CimMethod [[-Arguments] <IDictionary> ] [-MethodName] <String> -ResourceUri <Uri> [-ComputerName <String[]> ] [-Namespace <String> ] [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: ResourceUriSessionSet
Invoke-CimMethod [[-Arguments] <IDictionary> ] [-MethodName] <String> -CimSession <CimSession[]> -ResourceUri <Uri> [-Namespace <String> ] [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]




자세한 설명

The Invoke-CimMethod cmdlet invokes a method of a CIM class or CIM instance using the name-value pairs specified by the Arguments parameter.

If the InputObject parameter is not specified, the cmdlet works in one of the following ways:

--If neither the ComputerName parameter nor the CimSession parameter is specified, then this cmdlet works on local Windows Management Instrumentation (WMI) using a Component Object Model (COM) session.
--If either the ComputerName parameter or the CimSession parameter is specified, then this cmdlet works against the CIM server specified by either the ComputerName parameter or the CimSession parameter.

If the InputObject parameter is specified, the cmdlet works in one of the following ways:

--If neither the ComputerName parameter nor the CimSession parameter is specified, then this cmdlet uses the CIM session or computer name from the input object.
--If the either the ComputerName parameter or the CimSession parameter is specified, then this cmdlet uses the either the CimSession parameter value or ComputerName parameter value. Note: This is not very common.

매개 변수

-Arguments<IDictionary>

Specifies the parameters to pass to the called method. Specify the values for this parameter as name-value pairs, stored in a hash table. The order of the values entered are not important.


별칭

없음

필수 여부

false

위치

2

기본값

없음

파이프라인 입력 적용 여부

True (ByPropertyName)

와일드카드 문자 허용 여부

false

-CimClass<CimClass>

Specifies a CIM class object that represents a CIM class definition on the server. Use this parameter when invoking a static method of a class.

You can use the Get-CimClass cmdlet to retrieve a class definition from the server.

Using this parameter results in better client side schema validations.


별칭

없음

필수 여부

true

위치

1

기본값

없음

파이프라인 입력 적용 여부

True (ByValue)

와일드카드 문자 허용 여부

false

-CimSession<CimSession[]>

Runs the command using the specified CIM session. 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.


별칭

없음

필수 여부

true

위치

named

기본값

없음

파이프라인 입력 적용 여부

True (ByValue)

와일드카드 문자 허용 여부

false

-ClassName<String>

Specifies the name of the CIM class for which to perform the operation. This parameter is only used for static methods.
NOTE: You can use tab completion to browse the list of classes, because Windows PowerShell gets a list of classes from the local WMI server to provide a list of class names.


별칭

Class

필수 여부

true

위치

1

기본값

없음

파이프라인 입력 적용 여부

True (ByPropertyName)

와일드카드 문자 허용 여부

false

-ComputerName<String[]>

Specifies the name of 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, connecting using a CIM session gives better performance.


별칭

CN,ServerName

필수 여부

false

위치

named

기본값

없음

파이프라인 입력 적용 여부

True (ByPropertyName)

와일드카드 문자 허용 여부

false

-InputObject<CimInstance>

Specifies a CIM instance object to use as input to invoke a method.

This parameter can only be used to invoke instance methods. To invoke class static methods, use the Class parameter or the CimClass parameter.


별칭

CimInstance

필수 여부

true

위치

1

기본값

없음

파이프라인 입력 적용 여부

True (ByValue)

와일드카드 문자 허용 여부

false

-MethodName<String>

Specifies the name of the CIM method to invoke. This parameter is mandatory and cannot be null or empty.

To invoke static method of a CIM class use the ClassName or the CimClass parameter.


별칭

Name

필수 여부

true

위치

3

기본값

없음

파이프라인 입력 적용 여부

True (ByPropertyName)

와일드카드 문자 허용 여부

false

-Namespace<String>

Specifies the namespace for the CIM operation.

The default namespace is root/cimv2.
NOTE: You can use tab completion to browse the list of namespaces, because Windows PowerShell gets a list of namespaces from the local WMI server to provide the list of namespaces.


별칭

없음

필수 여부

false

위치

named

기본값

없음

파이프라인 입력 적용 여부

True (ByPropertyName)

와일드카드 문자 허용 여부

false

-OperationTimeoutSec<UInt32>

Specifies the amount of time that the cmdlet waits for a response from the computer.

By default, the value 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.


별칭

OT

필수 여부

false

위치

named

기본값

없음

파이프라인 입력 적용 여부

false

와일드카드 문자 허용 여부

false

-Query<String>

Specifies a query to run on the CIM server. A method is invoked on the instances received as a result of the query.

You can specify the query dialect using the QueryDialect parameter.

If the value specified contains double quotes (“), single quotes (‘), or a backslash (\), you must escape those characters by prefixing them with the backslash (\) character. If the value specified uses the WQL LIKE operator, then you must escape the following characters by enclosing them in square brackets ([]): percent (%), underscore (_), or opening square bracket ([).


별칭

없음

필수 여부

true

위치

named

기본값

없음

파이프라인 입력 적용 여부

True (ByPropertyName)

와일드카드 문자 허용 여부

false

-QueryDialect<String>

Specifies the query language used for the Query parameter. 이 매개 변수에 허용되는 값은 다음과 같습니다. WQL or CQL.

The default value is WQL.


별칭

없음

필수 여부

false

위치

named

기본값

없음

파이프라인 입력 적용 여부

True (ByPropertyName)

와일드카드 문자 허용 여부

false

-ResourceUri<Uri>

Specifies the resource uniform resource identifier (URI) of the resource class or instance. The URI is used to identify a specific type of resource, such as disks or processes, on a computer.

A URI consists of a prefix and a path to a resource. For example:

HYPERLINK "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_LogicalDisk" http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_LogicalDisk
HYPERLINK "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_GeneralSettings" http://intel.com/wbem/wscim/1/amt-schema/1/AMT_GeneralSettings

By default, if you do not specify this parameter, the DMTF standard resource URI http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/ is used and the class name is appended to it.

ResourceURI can only be used with CIM sessions created using the WSMan protocol, or when specifying the ComputerName parameter, which creates a CIM session using WSMan. If you specify this parameter without specifying the ComputerName parameter, or if you specify a CIM session created using DCOM protocol, you will get an error, because the DCOM protocol does not support the ResourceURI parameter.

If both the ResourceUri parameter and the Filter parameter are specified, the Filter parameter is ignored.


별칭

없음

필수 여부

true

위치

named

기본값

없음

파이프라인 입력 적용 여부

True (ByPropertyName)

와일드카드 문자 허용 여부

false

-Confirm

cmdlet을 실행하기 전에 확인 메시지가 표시됩니다.


필수 여부

false

위치

named

기본값

false

파이프라인 입력 적용 여부

false

와일드카드 문자 허용 여부

false

-WhatIf

cmdlet이 실행될 경우 결과 동작을 표시합니다. cmdlet이 실행되지 않습니다.


필수 여부

false

위치

named

기본값

false

파이프라인 입력 적용 여부

false

와일드카드 문자 허용 여부

false

<CommonParameters>

이 cmdlet은 일반 매개 변수 -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer 및 -OutVariable을 지원합니다. 자세한 내용은 다음을 참조하세요. about_CommonParameters(http://go.microsoft.com/fwlink/p/?LinkID=113216).

입력

입력 유형은 cmdlet에 파이프할 수 있는 개체의 유형입니다.

  • CIM class

    This cmdlet accepts a CIM class as an input object.


  • CIM instance

    This cmdlet accepts a CIM instance as an input object.


출력

출력 유형은 cmdlet이 내보내는 개체의 유형입니다.

  • System.Management.Automation.PSCustomObject

    This cmdlet returns an object.


예제

Example 1: Invoke a method

This command invokes the method named Terminate on the CIM class named Win32_Process. The CIM class is retrieved by the query "Select * from Win32_Process where name like ꞌnotepad%ꞌ".


PS C:\> Invoke-CimMethod –Query ꞌselect * from Win32_Process where name like "notepad%"ꞌ –MethodName "Terminate"

Example 2: Invoke a method using CIM instance object

This set of commands retrieves the CIM instance object and stores it in a variable named $x using the Get-CimInstance cmdlet. The contents of the variable are then used as the InputObject for the Invoke-CimMethod cmdlet, and the GetOwner method is invoked for the CimInstance.


 

PS C:\> $x = Get-CimInstance -Query ꞌSelect * from Win32_Process where name like "notepad%"

 

PS C:\> Invoke-CimMethod -InputObject $x -MethodName GetOwner

Example 3: Invoke a static method

This command invokes the static method Create on the class named Win32_Process with the arguments specified by the Arguments parameter.


PS C:\> Invoke-CimMethod –ClassName Win32_Process –MethodName "Create" –Arguments @{ Path = "notepad.exe" }

Example 4: Invoke a method using arguments

This command invokes the method named Create using the Arguments parameter.


PS C:\> Invoke-CimMethod -ClassName Win32_Process -MethodName "Create" -Arguments @{ CommandLine = ꞌnotepad.exeꞌ; CurrentDirectory = "C:\windows\system32" }

Example 5: Client-side validation

This set of commands does client-side validation for the method named xyz by passing a CimClass object to the Invoke-CimMethod cmdlet.


 

PS C:\> $c = Get-CimClass –ClassName Win32_Process

 

PS C:\> Invoke-CimMethod -CimClass $c -MethodName "xyz" –Arguments @{ CommandLine = ꞌnotepad.exeꞌ }

관련 항목

커뮤니티 추가 항목

추가
표시: