CmdID

CmdID / PowerShell / Cmdlets / New

New-CimInstance

Creates a CIM instance. PowerShell reference

From the PowerShell reference 12 parameters Alias ncim

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Creates a CIM instance. 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. By default, the New-CimInstance cmdlet creates an instance on the local computer.

New-CimInstance [-ClassName] <String> [-Key <String[]>] [[-Property] <IDictionary>] [-Namespace <String>] [-OperationTimeoutSec <UInt32>] [-ComputerName <String[]>] [-ClientOnly] [-WhatIf] [-Confirm] [<CommonParameters>]
New-CimInstance [-ClassName] <String> [-Key <String[]>] [[-Property] <IDictionary>] [-Namespace <String>] [-OperationTimeoutSec <UInt32>] -CimSession <CimSession[]> [-ClientOnly] [-WhatIf] [-Confirm] [<CommonParameters>]
New-CimInstance -ResourceUri <Uri> [-Key <String[]>] [[-Property] <IDictionary>] [-Namespace <String>] [-OperationTimeoutSec <UInt32>] -CimSession <CimSession[]> [-WhatIf] [-Confirm] [<CommonParameters>]
New-CimInstance -ResourceUri <Uri> [-Key <String[]>] [[-Property] <IDictionary>] [-Namespace <String>] [-OperationTimeoutSec <UInt32>] [-ComputerName <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-CimInstance [-CimClass] <CimClass> [[-Property] <IDictionary>] [-OperationTimeoutSec <UInt32>] -CimSession <CimSession[]> [-ClientOnly] [-WhatIf] [-Confirm] [<CommonParameters>]
New-CimInstance [-CimClass] <CimClass> [[-Property] <IDictionary>] [-OperationTimeoutSec <UInt32>] [-ComputerName <String[]>] [-ClientOnly] [-WhatIf] [-Confirm] [<CommonParameters>]

Create an instance of a CIM class

$prop = @{ Name = "testvar" VariableValue = "testvalue" UserName = "domain\user" } New-CimInstance -ClassName Win32_Environment -Property $propIdentify

Create an instance of a CIM class using a class schema

$class = Get-CimClass -ClassName Win32_Environment $prop = @{ Name = "testvar" VariableValue = "testvalue" UserName = "Contoso\User1" } New-CimInstance -CimClass $class -Property $propIdentify

Create a dynamic instance on the client

$instance = @{ ClassName = 'Win32_Process' Property = @{ Handle = 0 } Key = 'Handle' ClientOnly = $true } $a = New-CimInstance @instance Get-CimInstance -CimInstance $a Invoke-CimMethod -CimInstance $a -MethodName GetOwnerIdentify

Create an instance for a CIM class of a specific namespace

$class = Get-CimClass -ClassName MSFT_Something -Namespace root/somewhere New-CimInstance -CimClass $class -Property @{"Prop1"=1;"Prop2"="value"} -ClientOnlyIdentify

Its page in the reference: New-CimInstance.

Parameters

12 in the PowerShell reference
-CimClassSpecifies a CIM class object that represents the type of the instance. Use the Get-CimClass cmdlet to retrieve the class declaration from a computer. Using this parameter results in better client side schema validations.
-CimSessionRuns 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_CimSession.
-ClassNameSpecifies 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 PowerShell gets a list of classes from the local WMI server to provide a list of class names.
-ClientOnlyIndicates that the instance is only created in PowerShell without going to the CIM server. You can use this parameter to create an in-memory CIM instance for use in subsequent PowerShell operations.
-ComputerNameSpecifies 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.
-KeySpecifies the properties that are used as keys. CimSession and ComputerName cannot be used when Key is specified.
-NamespaceSpecifies the namespace of the class for the new instance. 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.
-OperationTimeoutSecSpecifies 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.
-PropertySpecifies 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.
-ResourceUriSpecifies 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.
-ConfirmPrompts you for confirmation before running the cmdlet.
-WhatIfShows what would happen if the cmdlet runs. The cmdlet is not run.