Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

Set-WmiInstance

Updated: August 9, 2015

Set-WmiInstance

Creates or updates an instance of an existing Windows Management Instrumentation (WMI) class.

Aliases

The following abbreviations are aliases for this cmdlet: 

  • swmi

Syntax

Parameter Set: class
Set-WmiInstance [-Class] <String> [[-Arguments] <Hashtable> ] [-AsJob] [-Authentication <AuthenticationLevel> {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged} ] [-Authority <String> ] [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-EnableAllPrivileges] [-Impersonation <ImpersonationLevel> {Default | Anonymous | Identify | Impersonate | Delegate} ] [-Locale <String> ] [-Namespace <String> ] [-PutType <PutType> {None | UpdateOnly | CreateOnly | UpdateOrCreate} ] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: list
Set-WmiInstance [-AsJob] [-Authentication <AuthenticationLevel> {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged} ] [-Authority <String> ] [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-EnableAllPrivileges] [-Impersonation <ImpersonationLevel> {Default | Anonymous | Identify | Impersonate | Delegate} ] [-Locale <String> ] [-Namespace <String> ] [-PutType <PutType> {None | UpdateOnly | CreateOnly | UpdateOrCreate} ] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: object
Set-WmiInstance -InputObject <ManagementObject> [-Arguments <Hashtable> ] [-AsJob] [-PutType <PutType> {None | UpdateOnly | CreateOnly | UpdateOrCreate} ] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: path
Set-WmiInstance -Path <String> [-Arguments <Hashtable> ] [-AsJob] [-Authentication <AuthenticationLevel> {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged} ] [-Authority <String> ] [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-EnableAllPrivileges] [-Impersonation <ImpersonationLevel> {Default | Anonymous | Identify | Impersonate | Delegate} ] [-Locale <String> ] [-Namespace <String> ] [-PutType <PutType> {None | UpdateOnly | CreateOnly | UpdateOrCreate} ] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: query
Set-WmiInstance [-AsJob] [-Authentication <AuthenticationLevel> {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged} ] [-Authority <String> ] [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-EnableAllPrivileges] [-Impersonation <ImpersonationLevel> {Default | Anonymous | Identify | Impersonate | Delegate} ] [-Locale <String> ] [-Namespace <String> ] [-PutType <PutType> {None | UpdateOnly | CreateOnly | UpdateOrCreate} ] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: WQLQuery
Set-WmiInstance [-AsJob] [-Authentication <AuthenticationLevel> {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged} ] [-Authority <String> ] [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-EnableAllPrivileges] [-Impersonation <ImpersonationLevel> {Default | Anonymous | Identify | Impersonate | Delegate} ] [-Locale <String> ] [-Namespace <String> ] [-PutType <PutType> {None | UpdateOnly | CreateOnly | UpdateOrCreate} ] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]




Detailed Description

The Set-WmiInstance cmdlet creates or updates an instance of an existing Windows Management Instrumentation (WMI) class. The created or updated instance is written to the WMI repository.

New CIM cmdlets, introduced Windows PowerShell 3.0, perform the same tasks as the WMI cmdlets. The CIM cmdlets comply with WS-Management (WSMan) standards and with the Common Information Model (CIM) standard. This enables cmdlets to use the same techniques to manage Windows-based computers and those running other operating systems. Instead of using Set-WmiInstance, consider using the Set-CimInstance or New-CimInstance cmdlets.

Parameters

-Arguments<Hashtable>

Specifies the name of the property to be changed and the new value for that property. The name and value must be a name-value pair. The name-value pair is passed on the command line as a hash table. For example:

@{Setting1=1; Setting2=5; Setting3="test"}


Aliases

Args,Property

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-AsJob

Indicates that this cmdket runs as a background job. Use this parameter to run commands that take a long time to finish.

When you specify the AsJob parameter, the command returns an object that represents the background job and then displays the command prompt. You can continue to work in the session while the job finishes. If Set-WmiInstance is used for 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 cmdlets that contain the Job noun (the Job cmdlets). To get the job results, use the Receive-Job cmdlet.

To use this parameter together 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 the Windows operating system. For more information, see about_Remote_Requirements.

For more information about Windows PowerShell background jobs, see about_Jobs and about_Remote_Jobs.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Authentication<AuthenticationLevel>

Specifies the authentication level that must be used with the WMI connection. The acceptable values for this parameter 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 start 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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Authority<String>

Specifies the authority to use to authenticate the WMI connection. You can 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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Class<String>

Specifies the name of a WMI class.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ComputerName<String[]>

Specifies the name of the computer on which this cmdlet runs. The default is the local computer.

Type the NetBIOS name, an IP address, or a fully qualified domain name of one or more computers. To specify the local computer, type the computer name, a dot (.), or localhost.

This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter even if your computer is not configured to run remote commands.


Aliases

Cn

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Credential<PSCredential>

Specifies a user account that has permission to perform this action. The default is the current user.

Type a user name, such as User01 or Domain01\User01, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, this cmdlet prompts for a password.

This parameter is not supported by any providers installed with parameter is not supported by any providers installed with Windows PowerShell.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-EnableAllPrivileges

Indicates that this cmdlet enables all the permissions of the current user before the command it makes the WMI call.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Impersonation<ImpersonationLevel>

Specifies the impersonation level to use. The acceptable values for this parameter 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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InputObject<ManagementObject>

Specifies a ManagementObject object to use as input. When this parameter is used, all other parameters ,except the Arguments parameter, are ignored.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-Locale<String>

Specifies the preferred locale for WMI objects. The Locale parameter is specified in an array in the MS_<LCID> format in the preferred order.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Namespace<String>

Specifies the WMI repository namespace where the referenced WMI class is located when it is used with the Class parameter.


Aliases

NS

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Path<String>

Specifies a WMI object path of the instance that you want to create or update.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PutType<PutType>

Indicates whether to create or update the WMI instance. The acceptable values for this parameter are:

-- UpdateOnly. Updates an existing WMI instance.
-- CreateOnly. Creates a new WMI instance.
-- UpdateOrCreate. Updates the WMI instance if it exists or creates a new instance if an instance does not exist.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ThrottleLimit<Int32>

Specifies the maximum number of concurrent connections that can be established to run this command. 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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see    about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • None

    This cmdlet does not accept input.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • None

    This cmdlet does not generate output.


Examples

Example 1: Set WMI logging level

This command sets the WMI logging level to 2. The command passes the property to be set and the value, together considered a value pair, in the argument parameter. The parameter takes a hash table that is defined by the @{property = value} construction. The class information that is returned reflects the new value.


PS C:\> Set-WmiInstance -Class Win32_WMISetting -Argument @{LoggingLevel=2}

Example 2: Create an environment variable and its value

This command creates the testvar environment variable that has the value testvalue. It does this by creating a new instance of the Win32_Environment WMI class. This operation requires appropriate credentials and that you may have to restart Windows PowerShell to see the new environment variable.


PS C:\> Set-WmiInstance -Class win32_environment -Argument @{Name="testvar";VariableValue="testvalue";UserName="<SYSTEM>"}

Example 3: Set WMI logging level for several remote computers

This command sets the WMI logging level to 2. The command passes the property to be set and the value, together considered a value pair, in the argument parameter. The parameter takes a hash table that is defined by the @{property = value} construction. The returned class information reflects the new value.


PS C:\> Set-WmiInstance -Class Win32_WMISetting -Argument @{LoggingLevel=2} -Computername "system01", "system02", "system03"

Related topics

Community Additions

ADD
Show:
© 2016 Microsoft