New-CimInstance

Windows Server 2012 R2 and Windows 8.1

New-CimInstance

Creates a CIM instance.

구문

Parameter Set: ClassNameComputerSet
New-CimInstance [-ClassName] <String> [[-Property] <IDictionary> ] [-ClientOnly] [-ComputerName <String[]> ] [-Key <String[]> ] [-Namespace <String> ] [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: CimClassComputerSet
New-CimInstance [-CimClass] <CimClass> [[-Property] <IDictionary> ] [-ClientOnly] [-ComputerName <String[]> ] [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: CimClassSessionSet
New-CimInstance [-CimClass] <CimClass> [[-Property] <IDictionary> ] -CimSession <CimSession[]> [-ClientOnly] [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: ClassNameSessionSet
New-CimInstance [-ClassName] <String> [[-Property] <IDictionary> ] -CimSession <CimSession[]> [-ClientOnly] [-Key <String[]> ] [-Namespace <String> ] [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: ResourceUriComputerSet
New-CimInstance [[-Property] <IDictionary> ] -ResourceUri <Uri> [-ComputerName <String[]> ] [-Key <String[]> ] [-Namespace <String> ] [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: ResourceUriSessionSet
New-CimInstance [[-Property] <IDictionary> ] -CimSession <CimSession[]> -ResourceUri <Uri> [-Key <String[]> ] [-Namespace <String> ] [-OperationTimeoutSec <UInt32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]




자세한 설명

The New-CimInstance cmdlet creates an instance of a CIM class based on the class definition on either the local computer or a remote computer.

Use the Property parameter to set the initial values of the selected properties.

By default, the New-CimInstance cmdlet creates an instance on the local computer.

매개 변수

-CimClass<CimClass>

Specifies a CIM class object that represents the type of the instance.

You can use the Get-CimClass cmdlet to retrieve the class declaration from a computer.

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 of which the operation creates an instance.
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.


별칭

없음

필수 여부

true

위치

1

기본값

없음

파이프라인 입력 적용 여부

True (ByPropertyName)

와일드카드 문자 허용 여부

false

-ClientOnly

Indicates that the instance is only created in Windows PowerShell® without going to the CIM server. You can use this parameter to create an in-memory CIM instance for use in subsequent Windows PowerShell operations.


별칭

Local

필수 여부

false

위치

named

기본값

없음

파이프라인 입력 적용 여부

false

와일드카드 문자 허용 여부

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 Ws-Man 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

-Key<String[]>

Specifies the properties that are used as keys. CimSession and ComputerName cannot be used when Key is specified.


별칭

없음

필수 여부

false

위치

named

기본값

없음

파이프라인 입력 적용 여부

True (ByPropertyName)

와일드카드 문자 허용 여부

false

-Namespace<String>

Specifies the namespace of the class for the new instance.

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 CIM server.

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.


별칭

OT

필수 여부

false

위치

named

기본값

없음

파이프라인 입력 적용 여부

false

와일드카드 문자 허용 여부

false

-Property<IDictionary>

Specifies the properties of the CIM instance using a hash table (name-value pairs).

If you specify the CimClass parameter, then the New-CimInstance cmdlet performs a property validation on the client to make sure that the properties specified are consistent with the class declaration on the server. If the CimClass parameter is not specified, then the property validation is done on the server.


별칭

Arguments

필수 여부

false

위치

2

기본값

없음

파이프라인 입력 적용 여부

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:

http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_LogicalDisk
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에 파이프할 수 있는 개체의 유형입니다.

  • None

    This cmdlet accepts no input objects.


출력

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

  • System.Object

    This cmdlet returns an object that contains the CIM instance information.


예제

Example 1: Create an instance of a CIM class

This command creates an instance of a CIM Class named win32_environment in the root/cimv2 namespace on the computer.

No client side validation is performed if the class does not exist, the properties are wrong, or if the server rejects the call.

If the instance is created successfully, then the New-CimInstance cmdlet outputs the newly created instance.


PS C:\> New-CimInstance -ClassName Win32_Environment -Property @{Name="testvar";VariableValue="testvalue";UserName="domain\user"}

Example 2: Create an instance of a CIM class using a class schema

This set of commands retrieves a CIM class object and stores it in a variable named $class using the Get-CimClass cmdlet. The contents of the variable are then passed to the New-CimInstance cmdlet.


 

PS C:\> $class = Get-CimClass -ClassName Win32_Environment

 

PS C:\> New-CimInstance -CimClass $class -Property @{Name="testvar";VariableValue="testvalue";UserName="Contoso\User1"}

Example 3: Create a dynamic instance on the client

This set of commands creates a dynamic instance of a CIM class named win32_Process on the client computer without getting the instance from the server. This set of commands retrieves the dynamic instance and stores it in a variable named $a and passes the contents of the variable to the Get-CimInstance cmdlet. The Get-CimInstance cmdlet then retrieves a particular single instance, and invokes the GetOwner method using the Invoke-CimMethod cmdlet.

This dynamic instance can be used to perform operations if the instance with this key exists on the server.


 

PS C:\> $a = New-CimInstance -ClassName Win32_Process -Property @{Handle=0} -Key Handle -ClientOnly

 

PS C:\> Get-CimInstance –CimInstance $a

 

PS C:\> Invoke-CimMethod -CimInstance $a -MethodName GetOwner

Example 4: Create an instance for a CIM class of a specific namespace

This set of commands gets an instance of a CIM class named MSFT_Something in the namespace root/somewhere and stores it in a variable named $class using the Get-CimClass cmdlet. The contents of the variable are then passed to the New-CimInstance cmdlet to create a new CIM instance and perform client side validations on the new instance.

If you want to validate the instance, for example, to make sure Prop1 and Prop2 actually exist and that the keys are marked correctly, use the CimClass parameter instead of the ClassName parameter.

You cannot use the ComputerName or CimSession parameter with the ClientOnly parameter.


 

PS C:\> $class = Get-CimClass -ClassName MSFT_Something -Namespace root/somewhere

 

PS C:\> New-CimInstance -CimClass $class -Property @{"Prop1"=1;"Prop2"="value"} -ClientOnly

관련 항목

커뮤니티 추가 항목

추가
표시: