Create or update an instance of an existing Windows Management Instrumentation (WMI) class.
The preferred cmdlet is now Set-CIMInstance.

      Set-WmiInstance [ [-Class] string [-Arguments] hashtable] ]
        [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged}]
           [-Authority string] [-ComputerName string[]] [-Credential PSCredential] [-EnableAllPrivileges]
              [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}]
                 [-Locale string] [-Namespace string] [-AsJob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}]
                    [-ThrottleLimit int] [-Confirm] [-WhatIf] [CommonParameters]

      Set-WmiInstance -InputObject ManagementObject [-Arguments hashtable]
        [-AsJob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}]
           [-ThrottleLimit int] [-Confirm] [-WhatIf] [CommonParameters]

      Set-WmiInstance -Path string [-Arguments hashtable]
        [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged}]
           [-Authority string] [-ComputerName string[]] [-Credential PSCredential] [-EnableAllPrivileges]
              [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}]
                 [-Locale string] [-Namespace string] [-AsJob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}]
                    [-ThrottleLimit int] [-Confirm] [-WhatIf] [CommonParameters]

   -Arguments hashtable
       The name of the property to be changed and the new value for that property.
       The name-value pair must be passed on the command-line as a hash table. For example:
              -argument @{Setting1=1; Setting2=5; Setting3="test"}.

       Run the command as a background job. Use this to run commands that take a long time to finish.
       When -AsJob is used, the command will return an object representing the background job and
       then display the command prompt. You can continue to work in the session while the job finishes.
       If Set-WmiObject is used against a remote computer, the job is created on the local computer, and
       the results from remote computers are automatically returned to the local computer.
       To manage the job, use the job- cmdlets. To get the job results, use Receive-Job.

       Note: To use this parameter with remote computers, the local and remote computers must be configured
       for remoting. Additionally, you must start Windows PowerShell by using the "Run as administrator" option
       in Windows Vista and later versions of Windows. For more information, see about_Remote_Requirements.
        For more information about Windows PowerShell background jobs, see  about_Jobs and about_Remote_Jobs.

   -Authentication Authentication
       The authentication mechanism to be used with the WMI connection. Possible values are:
       -1: Unchanged
        0: Default
        1: None (No authentication in performed.)
        2: Connect (Authentication is performed only when the client establishes a relationship with the application.)
        3: Call (Authentication is performed only at the beginning of each call when
                 the application receives the request.)
        4: Packet (Authentication is performed on all the data that is received from the client.)
        5: PacketIntegrity (All the data that is transferred between the client and the application is
                            authenticated and verified.)
        6: PacketPrivacy (The properties of the other authentication levels are used, and all the data is encrypted.)

   -Authority string
       The authority to use to authenticate the WMI connection.
       Specify standard NTLM or Kerberos authentication. To use NTLM, set the authority setting to
       ntlmdomain:DomainName, where DomainName identifies a valid NTLM domain name.
       To use Kerberos, specify kerberos:DomainName\ServerName".
       You cannot include the authority setting when you connect to the local computer.

   -Class string
       The name of a WMI class.

   -ComputerName string[]
       The computer against which you want to run the management operation.
       A fully qualified domain name, NetBIOS name, or an IP address.
       Use the local computer name, localhost, or a dot (.) to specify the local computer.
       The local computer is the default. When the remote computer is in a different domain,
       use a fully qualified domain name. You can pipe a value for ComputerName.
       (This parameter does not rely on Windows PowerShell remoting)

   -Credential PSCredential
       A user account that has permission to perform this action. default=current user.
       e.g. "User01", "Domain01\User01", or "". Or a PSCredential object, such as 
       returned by the Get-Credential cmdlet. When you type a user name, you will be prompted for a password.
   -EnableAllPrivileges [<SwitchParameter>]
       Enables all the privileges of the current user before the command makes the WMI call .

   -Impersonation ImpersonationLevel
       The impersonation level to use. Valid values are: 

        0: Default (Reads the local registry for the default impersonation level, which is usually set to "3: Impersonate".)
        1: Anonymous (Hides the credentials of the caller.)
        2: Identify (Allows objects to query the credentials of the caller.)
        3: Impersonate (Allows objects to use the credentials of the caller.)
        4: Delegate (Allows objects to permit other objects to use the credentials of the caller.)

   -InputObject ManagementObject
      A ManagementObject object to use as input.
      When this parameter is used, all other parameters ,except for -Arguments, are ignored.

   -Locale string
      The preferred locale for WMI objects.
      The Locale parameter is specified in an array in the MS_LCID  format in the preferred order.

   -Namespace string
      When used with -Class, this specifies the WMI repository namespace where the referenced 
      WMI class is located.

   -Path string
       A WMI object path to the instance that you want to create or update.

   -PutType PutType
       Indicates whether the WMI instance should be created or updated. Valid values are:

        UpdateOnly      Update an existing WMI instance.
        CreateOnly      Create a new WMI instance.
        UpdateOrCreate  Update the WMI instance if it exists or else create a new instance.

   -ThrottleLimit int
       Allow the user to specify a throttling value for the number of WMI operations that can be executed simultaneously.
       This parameter is used together with the AsJob parameter. 
       The throttle limit applies only to the current command, not to the session or to the computer.

       Prompt for confirmation before executing the command.

       Describe what would happen if you executed the command without actually executing the command.

Standard Aliases for Set-WmiInstance: swmi

Connect-WSMan establishes a persistent connection to the remote computer. You can connect to the WinRM service on a remote computer before or after you change to the WS-Management provider. The remote computer will appear in the root directory of the WS-Management provider.


Set the WMI logging level to 2, ( note the the property to be set and the value are passed together as a value pair):

PS C:\> Set-WmiInstance -class Win32_WMISetting -argument @{LoggingLevel=2}

Create the testvar environment variable that has the value "testvalue" (you may need to restart Windows PowerShell to see the new environment variable):

PS C:\> Set-WmiInstance -class win32_environment -argument @{Name="testvar";VariableValue="testvalue";UserName="<SYST

Set the WMI logging level to 2 on Server64 and Server65:

PS C:\> Set-WmiInstance -class Win32_WMISetting -argument @{LoggingLevel=2} -computername server64, server65

“From now on, I’ll connect the dots my own way” ~ Bill Watterson

Related PowerShell Cmdlets

Get-WmiObject - Get WMI class information.

Copyright © 1999-2024
Some rights reserved