The Windows PowerShell command Set-WmiInstance is a powerful tool for managing Windows Management Instrumentation (WMI) objects. It can be used to create, modify, and delete WMI objects, as well as query and set their properties. In this article, we will explore the syntax, parameters, inputs, outputs, examples, and tips for using Set-WmiInstance.

Syntax

The syntax for the Set-WmiInstance command is as follows:

Set-WmiInstance [-Class] <string> [-Namespace <string>] [-Arguments <hashtable>] [-ComputerName <string[]>] [-Impersonation <ImpersonationLevel>] [-Authentication <AuthenticationLevel>] [-EnableAllPrivileges] [-Credential <PSCredential>] [-ThrottleLimit <int>] [-AsJob] [-WhatIf] [-Confirm] [ <CommonParameters>]

Parameters

The Set-WmiInstance command has the following parameters:

Parameter Description
-Class Specifies the WMI class to be modified.
-Namespace Specifies the WMI namespace. The default is root\cimv2.
-Arguments Specifies a hash table of WMI property names and values to be set.
-ComputerName Specifies the name of the computer on which to run the command.
-Impersonation Specifies the impersonation level for the command.
-Authentication Specifies the authentication level for the command.
-EnableAllPrivileges Specifies that all privileges should be enabled for the command.
-Credential Specifies a user account that has permission to perform the operation.
-ThrottleLimit Specifies the maximum number of concurrent operations that can be established to run the command.
-AsJob Runs the command as a background job.
-WhatIf Describes what would happen if you executed the command without actually executing the command.
-Confirm Prompts you for confirmation before executing the command.

Inputs

The Set-WmiInstance command requires the following inputs:

  • The name of the WMI class to be modified.
  • The WMI namespace.
  • A hash table of WMI property names and values to be set.
  • The name of the computer on which to run the command.
  • The impersonation level for the command.
  • The authentication level for the command.
  • A user account that has permission to perform the operation.
  • The maximum number of concurrent operations that can be established to run the command.

Outputs

The Set-WmiInstance command does not produce any output.

Examples

The following example shows how to use the Set-WmiInstance command to set the StartMode property of the Win32_Service class to Auto:

Set-WmiInstance -Class Win32_Service -Arguments @{StartMode=”Auto”}

The following example shows how to use the Set-WmiInstance command to set the StartMode property of the Win32_Service class to Auto on a remote computer:

Set-WmiInstance -Class Win32_Service -ComputerName “MyComputer” -Arguments @{StartMode=”Auto”}

Tips

When using the Set-WmiInstance command, keep the following tips in mind:

  • Make sure you have the necessary permissions to modify the WMI class.
  • If you are running the command on a remote computer, make sure you have the necessary permissions on the remote computer.
  • Make sure you specify the correct WMI namespace.
  • Make sure you specify the correct property names and values.
  • If you are running the command on a remote computer, you may need to specify a user account with the necessary permissions.

Conclusion

The Set-WmiInstance command is a powerful tool for managing WMI objects. It can be used to create, modify, and delete WMI objects, as well as query and set their properties. In this article, we have explored the syntax, parameters, inputs, outputs, examples, and tips for using Set-WmiInstance.

Leave a Reply