Windows PowerShell is a powerful command-line shell and scripting language that helps administrators to automate system management tasks. It provides a set of cmdlets that can be used to perform various operations on Windows systems. One of the most commonly used cmdlets is the Set-CimInstance cmdlet. This cmdlet allows administrators to create, modify, and delete CIM (Common Information Model) instances on remote computers. In this article, we will discuss the syntax, parameters, inputs, outputs, examples, and tips for using the Set-CimInstance cmdlet.

What is Set-CimInstance?

Set-CimInstance is a Windows PowerShell cmdlet that allows administrators to create, modify, and delete CIM (Common Information Model) instances on remote computers. CIM is a standard for describing management information in a platform-independent way. It is used to represent the configuration of a system, such as hardware, software, and services. The Set-CimInstance cmdlet can be used to create, modify, or delete CIM instances on remote computers. It can also be used to query CIM instances on remote computers.

Syntax of Set-CimInstance

The syntax of the Set-CimInstance cmdlet is as follows:

Set-CimInstance [-ClassName] <String> [-ComputerName <String[]>] [-Key <String[]>] [-InputObject <CimInstance[]>] [-Property <Hashtable>] [-Query <String>] [-QueryDialect <String>] [-ReturnImmediately] [-ThrottleLimit <Int32>] [-AsJob] [-CimSession <CimSession[]>] [-EnableAllPrivileges] [-Locale <String>] [-OperationTimeoutSec <Int32>] [-Passthru] [-Port <UInt32>] [-Protocol <ProtocolType>] [-ResourceUri <Uri>] [-SessionOption <CimSessionOption>] [-SharedResouceName <String>] [-UseSsl] [-WhatIf] [-Confirm] [<CommonParameters>]

Parameters of Set-CimInstance

The Set-CimInstance cmdlet has the following parameters:

Parameter Description
ClassName The name of the CIM class.
ComputerName The name of the computer on which the CIM instance will be created, modified, or deleted.
Key The key properties of the CIM instance.
InputObject The CIM instance to be created, modified, or deleted.
Property The properties of the CIM instance.
Query The query used to select the CIM instance.
QueryDialect The query dialect used to select the CIM instance.
ReturnImmediately Indicates that the cmdlet should return immediately after sending the request to the remote computer.
ThrottleLimit The maximum number of concurrent operations that can be established to run the cmdlet.
AsJob Indicates that the cmdlet should be run as a background job.
CimSession The CIM session to use for the operation.
EnableAllPrivileges Indicates that the cmdlet should enable all privileges on the remote computer.
Locale The locale to use for the operation.
OperationTimeoutSec The timeout, in seconds, for the operation.
Passthru Indicates that the cmdlet should return the CIM instance.
Port The port to use for the operation.
Protocol The protocol to use for the operation.
ResourceUri The resource URI to use for the operation.
SessionOption The session options to use for the operation.
SharedResourceName The name of the shared resource to use for the operation.
UseSsl Indicates that the cmdlet should use SSL for the operation.
WhatIf Indicates that the cmdlet should simulate the operation.
Confirm Indicates that the cmdlet should prompt the user for confirmation before running the cmdlet.

Inputs of Set-CimInstance

The Set-CimInstance cmdlet requires the following inputs:

  • ClassName: The name of the CIM class.
  • ComputerName: The name of the computer on which the CIM instance will be created, modified, or deleted.
  • Key: The key properties of the CIM instance.
  • InputObject: The CIM instance to be created, modified, or deleted.
  • Property: The properties of the CIM instance.
  • Query: The query used to select the CIM instance.
  • QueryDialect: The query dialect used to select the CIM instance.

Outputs of Set-CimInstance

The Set-CimInstance cmdlet returns the following outputs:

  • CimInstance: The CIM instance that was created, modified, or deleted.
  • Job: The job object that was created if the cmdlet was run as a background job.

Examples of Set-CimInstance

The following examples demonstrate how to use the Set-CimInstance cmdlet:

  • To create a CIM instance on a remote computer, use the following command:

    Set-CimInstance -ClassName Win32_Service -ComputerName “Server01″ -Property @{Name=”MyService”;StartMode=”Manual”;State=”Running”}

  • To modify a CIM instance on a remote computer, use the following command:

Leave a Reply