powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Set-WmiInstance



NAME
Set-WmiInstance

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

SYNTAX
Set-WmiInstance [-Class] [[-Arguments] ] [-Authentication {Default | None | Connect | Call | Pa
cket | PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority ] [-ComputerName ] [-Credential
] [-EnableAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [
-Locale ] [-Namespace ] [-AsJob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}] [-Thr
ottleLimit ] [-Confirm] [-WhatIf] []

Set-WmiInstance [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unch
anged}] [-Authority ] [-ComputerName ] [-Credential ] [-EnableAllPrivileges] [-Impe
rsonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Locale ] [-Namespace ] [-AsJ
ob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}] [-ThrottleLimit ] [-Confirm] [-WhatIf] [ onParameters>]

Set-WmiInstance -InputObject [-Arguments ] [-AsJob] [-PutType {None | UpdateOnly | Cr
eateOnly | UpdateOrCreate}] [-ThrottleLimit ] [-Confirm] [-WhatIf] []

Set-WmiInstance -Path [-Arguments ] [-Authentication {Default | None | Connect | Call | Packet
| PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority ] [-ComputerName ] [-Credential edential>] [-EnableAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Loca
le ] [-Namespace ] [-AsJob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}] [-Throttle
Limit ] [-Confirm] [-WhatIf] []

Set-WmiInstance [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unch
anged}] [-Authority ] [-ComputerName ] [-Credential ] [-EnableAllPrivileges] [-Impe
rsonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Locale ] [-Namespace ] [-AsJ
ob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}] [-ThrottleLimit ] [-Confirm] [-WhatIf] [ onParameters>]

Set-WmiInstance [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unch
anged}] [-Authority ] [-ComputerName ] [-Credential ] [-EnableAllPrivileges] [-Impe
rsonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Locale ] [-Namespace ] [-AsJ
ob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}] [-ThrottleLimit ] [-Confirm] [-WhatIf] [ onParameters>]


DESCRIPTION
The Set-WmiInstance cmdlet creates or updates an instance of an existing WMI class. The created or updated instance
is written to the WMI repository.


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

Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false

-AsJob []
Runs the command as a background job. Use this parameter to run commands that take a long time to finish.

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

Note: To use this parameter with remote computers, the local and remote computers must be configured for remoti
ng. 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.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Authentication
Specifies the authentication level to be used with the WMI connection. Valid 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 reque
st.)
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 a
nd verified.)
6: PacketPrivacy (The properties of the other authentication levels are used, and all the data is encrypted.)

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Authority
Specifies the authority to use to authenticate the WMI connection. You can specify standard NTLM or Kerberos au
thentication. To use NTLM, set the authority setting to ntlmdomain:, where identifies
a valid NTLM domain name. To use Kerberos, specify kerberos:\". You cannot include the
authority setting when you connect to the local computer.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Class
Specifies the name of a WMI class.

Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ComputerName
Specifies the computer against which you want to run the management operation. The value can be a fully qualifi
ed domain name, a NetBIOS name, or an IP address. Use the local computer name, use localhost, or use a dot (.)
to specify the local computer. The local computer is the default. When the remote computer is in a different do
main from the user, you must use a fully qualified domain name. You can set the value of this parameter by pipi
ng the value to the parameter.

This parameter does not rely on Windows PowerShell remoting, which uses WS-Management ). You can use the Comput
erName parameter of Get-WmiObject even if your computer is not configured to run WS-Management remote commands.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Credential
Specifies a user account that has permission to perform this action. The default is the current user. Type a us
er name, such as "User01", "Domain01\User01", or User@Contoso.com. Or, enter a PSCredential object, such as an
object that is returned by the Get-Credential cmdlet. When you type a user name, you will be prompted for a pas
sword.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-EnableAllPrivileges []
Enables all the privileges of the current user before the command makes the WMI call .

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Impersonation
Specifies 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: Impersona
te".)
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.)

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

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

Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

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

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

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

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

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

Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-PutType
Indicates whether the WMI instance should be created or updated. Valid values 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.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

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

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Confirm []
Prompts you for confirmation before executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-WhatIf []
Describes what would happen if you executed the command without actually executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS
None
This cmdlet does not accept input.


OUTPUTS
None
This cmdlet does not generate output.


NOTES





-------------------------- EXAMPLE 1 --------------------------

C:\PS>Set-WMIInstance -class Win32_WMISetting -argument @{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\ncprov.mof, %windir%\
syst
em32\wbem\wmipcima.mof, %windir%\system32\wbem\secrcw32.mof...}
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 :


Description
-----------
This command sets the WMI logging level to 2. The command passes the property to be set and the value (together con
sidered a value pair) in the argument parameter. The parameter takes a hash table that is defined by the @{property
= value} construction. Theclass information that is returned reflects the new value.





-------------------------- EXAMPLE 2 --------------------------

C:\PS>set-wmiinstance -class win32_environment -argument @{Name="testvar";VariableValue="testvalue";UserName=" EM>"}

__GENUS : 2
__CLASS : Win32_Environment
__SUPERCLASS : CIM_SystemResource
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_Environment.Name="testvar",UserName=""
__PROPERTY_COUNT : 8
__DERIVATION : {CIM_SystemResource, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER : SYSTEM01
__NAMESPACE : root\cimv2
__PATH : \\SYSTEM01\root\cimv2:Win32_Environment.Name="testvar",UserName=""
Caption : \testvar
Description : \testvar
InstallDate :
Name : testvar
Status : OK
SystemVariable : True
UserName :
VariableValue : testvalue


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





-------------------------- EXAMPLE 3 --------------------------

C:\PS>Set-WMIInstance -class Win32_WMISetting -argument @{LoggingLevel=2} -computername system01, system02, system0
3

__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\ncprov.mof, %windir%\
syst
em32\wbem\wmipcima.mof, %windir%\system32\wbem\secrcw32.mof...}
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 :

...


Description
-----------
This command sets the WMI logging level to 2. The command passes the property to be set and the value (together con
sidered 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.






RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113402
Get-WmiObject
Invoke-WmiMethod
Remove-WmiObject
Get-WSManInstance
Invoke-WSManAction
New-WSManInstance
Remove-WSManInstance