Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Set-WmiInstance
Creates or updates an instance of an existing Windows Management Instrumentation (WMI) class.
Syntax
Class (Default)
Set-WmiInstance
[-Class] <String>
[-Arguments <Hashtable>]
[-PutType <PutType>]
[-AsJob]
[-Impersonation <ImpersonationLevel>]
[-Authentication <AuthenticationLevel>]
[-Locale <String>]
[-EnableAllPrivileges]
[-Authority <String>]
[-Credential <PSCredential>]
[-ThrottleLimit <Int32>]
[-ComputerName <String[]>]
[-Namespace <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Object
Set-WmiInstance
-InputObject <ManagementObject>
[-Arguments <Hashtable>]
[-PutType <PutType>]
[-AsJob]
[-ThrottleLimit <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Path
Set-WmiInstance
-Path <String>
[-Arguments <Hashtable>]
[-PutType <PutType>]
[-AsJob]
[-Impersonation <ImpersonationLevel>]
[-Authentication <AuthenticationLevel>]
[-Locale <String>]
[-EnableAllPrivileges]
[-Authority <String>]
[-Credential <PSCredential>]
[-ThrottleLimit <Int32>]
[-ComputerName <String[]>]
[-Namespace <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
WQLQuery
Set-WmiInstance
[-PutType <PutType>]
[-AsJob]
[-Impersonation <ImpersonationLevel>]
[-Authentication <AuthenticationLevel>]
[-Locale <String>]
[-EnableAllPrivileges]
[-Authority <String>]
[-Credential <PSCredential>]
[-ThrottleLimit <Int32>]
[-ComputerName <String[]>]
[-Namespace <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Query
Set-WmiInstance
[-PutType <PutType>]
[-AsJob]
[-Impersonation <ImpersonationLevel>]
[-Authentication <AuthenticationLevel>]
[-Locale <String>]
[-EnableAllPrivileges]
[-Authority <String>]
[-Credential <PSCredential>]
[-ThrottleLimit <Int32>]
[-ComputerName <String[]>]
[-Namespace <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
List
Set-WmiInstance
[-PutType <PutType>]
[-AsJob]
[-Impersonation <ImpersonationLevel>]
[-Authentication <AuthenticationLevel>]
[-Locale <String>]
[-EnableAllPrivileges]
[-Authority <String>]
[-Credential <PSCredential>]
[-ThrottleLimit <Int32>]
[-ComputerName <String[]>]
[-Namespace <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
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.
Examples
Example 1: Set WMI logging level
Set-WmiInstance -Class Win32_WMISetting -Arguments @{LoggingLevel=2}
__GENUS : 2
__CLASS : Win32_WMISetting
__SUPERCLASS : CIM_Setting
__DYNASTY : CIM_Setting
__RELPATH : Win32_WMISetting=@
__PROPERTY_COUNT : 27
__DERIVATION : {CIM_Setting}
__SERVER : SYSTEM01
__NAMESPACE : root\cimv2
__PATH : \\SYSTEM01\root\cimv2:Win32_WMISetting=@
ASPScriptDefaultNamespace : \\root\cimv2
ASPScriptEnabled : False
AutorecoverMofs : {%windir%\system32\wbem\cimwin32.mof, %windir%\system32\wbem\n...}
AutoStartWin9X :
BackupInterval :
BackupLastTime :
BuildVersion : 6001.18000
Caption :
DatabaseDirectory : C:\Windows\system32\wbem\repository
DatabaseMaxSize :
Description :
EnableAnonWin9xConnections :
EnableEvents : False
EnableStartupHeapPreallocation : False
HighThresholdOnClientObjects :
HighThresholdOnEvents : 20000000
InstallationDirectory : C:\Windows\system32\wbem
LastStartupHeapPreallocation :
LoggingDirectory : C:\Windows\system32\wbem\Logs\
LoggingLevel : 2
LowThresholdOnClientObjects :
LowThresholdOnEvents : 10000000
MaxLogFileSize : 65536
MaxWaitOnClientObjects :
MaxWaitOnEvents : 2000
MofSelfInstallDirectory :
SettingID :
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's defined by the @{property = value} construction. The class information that's returned
reflects the new value.
Example 2: Create an environment variable and its value
$setWmiInstanceSplat = @{
Class = 'Win32_Environment'
Arguments = @{
Name="testvar"
VariableValue="testvalue"
UserName="<SYSTEM>"
}
}
Set-WmiInstance @setWmiInstanceSplat
__GENUS : 2
__CLASS : Win32_Environment
__SUPERCLASS : CIM_SystemResource
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_Environment.Name="testvar",UserName="<SYSTEM>"
__PROPERTY_COUNT : 8
__DERIVATION : {CIM_SystemResource, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER : SYSTEM01
__NAMESPACE : root\cimv2
__PATH : \\SYSTEM01\root\cimv2:Win32_Environment.Name="testvar",UserName="<SYSTEM>"
Caption : <SYSTEM>\testvar
Description : <SYSTEM>\testvar
InstallDate :
Name : testvar
Status : OK
SystemVariable : True
UserName : <SYSTEM>
VariableValue : testvalue
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.
Example 3: Set WMI logging level for several remote computers
$setWmiInstanceSplat = @{
Class = 'Win32_WMISetting'
Arguments = @{LoggingLevel = 2}
ComputerName = 'system01', 'system02', 'system03'
}
Set-WmiInstance @setWmiInstanceSplat
__GENUS : 2
__CLASS : Win32_WMISetting
__SUPERCLASS : CIM_Setting
__DYNASTY : CIM_Setting
__RELPATH : Win32_WMISetting=@
__PROPERTY_COUNT : 27
__DERIVATION : {CIM_Setting}
__SERVER : SYSTEM01
__NAMESPACE : root\cimv2
__PATH : \\SYSTEM01\root\cimv2:Win32_WMISetting=@
ASPScriptDefaultNamespace : \\root\cimv2
ASPScriptEnabled : False
AutorecoverMofs : {%windir%\system32\wbem\cimwin32.mof, %windir%\system32\wbem\n...}
AutoStartWin9X :
BackupInterval :
BackupLastTime :
BuildVersion : 6001.18000
Caption :
DatabaseDirectory : C:\Windows\system32\wbem\repository
DatabaseMaxSize :
Description :
EnableAnonWin9xConnections :
EnableEvents : False
EnableStartupHeapPreallocation : False
HighThresholdOnClientObjects :
HighThresholdOnEvents : 20000000
InstallationDirectory : C:\Windows\system32\wbem
LastStartupHeapPreallocation :
LoggingDirectory : C:\Windows\system32\wbem\Logs\
LoggingLevel : 2
LowThresholdOnClientObjects :
LowThresholdOnEvents : 10000000
MaxLogFileSize : 65536
MaxWaitOnClientObjects :
MaxWaitOnEvents : 2000
MofSelfInstallDirectory :
SettingID :
...
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's defined by the @{property = value} construction. The returned class information reflects
the new value.
Parameters
-Arguments
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"}
Parameter properties
| Type: | Hashtable |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | Args, Property |
Parameter sets
-AsJob
Indicates that this cmdlet 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 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 using the Run as administrator option. For more information, see about_Remote_Requirements.
For more information about Windows PowerShell background jobs, see about_Jobs and about_Remote_Jobs.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Authentication
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's received from the client.5: PacketIntegrity. All the data that's 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.
Parameter properties
| Type: | AuthenticationLevel |
| Default value: | None |
| Accepted values: | Default, None, Connect, Call, Packet, PacketIntegrity, PacketPrivacy, Unchanged |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Authority
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 can't include the authority setting when you connect to
the local computer.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Class
Specifies the name of a WMI class.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ComputerName
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 doesn't rely on Windows PowerShell remoting. You can use the ComputerName parameter even if your computer isn't configured to run remote commands.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | Cn |
Parameter sets
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
| Type: | SwitchParameter |
| Default value: | False |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | cf |
Parameter sets
-Credential
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 isn't supported by any providers installed with parameter isn't supported by any providers installed with Windows PowerShell.
Parameter properties
| Type: | PSCredential |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EnableAllPrivileges
Indicates that this cmdlet enables all the permissions of the current user before the command it makes the WMI call.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Impersonation
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.
Parameter properties
| Type: | ImpersonationLevel |
| Default value: | None |
| Accepted values: | Default, Anonymous, Identify, Impersonate, Delegate |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-InputObject
Specifies a ManagementObject object to use as input. When this parameter is used, all other parameters ,except the Arguments parameter, are ignored.
Parameter properties
| Type: | ManagementObject |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Locale
Specifies the preferred locale for WMI objects. The Locale parameter is specified in an array in
the MS_<LCID> format in the preferred order.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Namespace
Specifies the WMI repository namespace where the referenced WMI class is located when it's used with the Class parameter.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | NS |
Parameter sets
-Path
Specifies a WMI object path of the instance that you want to create or update.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-PutType
Indicates whether to create or update the WMI instance. The acceptable values for this parameter are:
UpdateOnlyUpdates an existing WMI instance.CreateOnlyCreates a new WMI instance.UpdateOrCreateUpdates the WMI instance if it exists or creates a new instance if an instance doesn't exist.
Parameter properties
| Type: | PutType |
| Default value: | None |
| Accepted values: | None, UpdateOnly, CreateOnly, UpdateOrCreate |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ThrottleLimit
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.
Parameter properties
| Type: | Int32 |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet isn't run.
Parameter properties
| Type: | SwitchParameter |
| Default value: | False |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | wi |
Parameter sets
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
None
This cmdlet doesn't accept input.
Outputs
None
This cmdlet doesn't generate output.
Notes
Windows PowerShell includes the following aliases for Set-WmiInstance:
swmi
Related Links
Feedback
Was this page helpful?
