Sets the binary data value of a named value.
Example
Do not run below example code just to see what happens next. Many methods seriously affect your system. Always make sure you actually understand what the method and the code do.
# define the arguments you want to submit to the method
# remove values that you do not want to submit
# make sure you replace values with meaningful content before running the code
# see section "Parameters" below for a description of each argument.
$arguments = @{
hDefKey = [UInt32](12345) # replace 12345 with a meaningful value
sSubKeyName = 'someText' # replace 'someText' with meaningful text
sValueName = 'someText' # replace 'someText' with meaningful text
uValue = [UInt8[]](12345) # replace 12345 with a meaningful value
}
Invoke-CimMethod -ClassName StdRegProv -Namespace Root/default -MethodName SetBinaryValue -Arguments $arguments
To run this method on one or more remote systems, use New-CimSession
:
$ComputerName = 'server12','server14' # adjust to your server names
$Credential = Get-Credential # submit a user account with proper permissions
# define the arguments you want to submit to the method
# remove values that you do not want to submit
# make sure you replace values with meaningful content before running the code
# see section "Parameters" below for a description of each argument.
$arguments = @{
hDefKey = [UInt32](12345) # replace 12345 with a meaningful value
sSubKeyName = 'someText' # replace 'someText' with meaningful text
sValueName = 'someText' # replace 'someText' with meaningful text
uValue = [UInt8[]](12345) # replace 12345 with a meaningful value
}
$session = New-CimSession -ComputerName $ComputerName -Credential $Credential
Invoke-CimMethod -ClassName StdRegProv -Namespace Root/default -MethodName SetBinaryValue -Arguments $arguments -CimSession $session
Remove-CimSession -CimSession $session
Learn more about
Invoke-CimMethod
and invoking WMI methods.
Syntax
uint32 SetBinaryValue(
[in] uint32 hDefKey = HKEY_LOCAL_MACHINE,
[in] string sSubKeyName,
[in] string sValueName,
[in] uint8 uValue[]
);
Parameters
Name | Type | Description |
---|---|---|
hDefKey | UInt32 | Optional parameter that specifies the tree that contains the sSubKeyName path. The default value is HKEY_LOCAL_MACHINE (0x80000002). The following trees are defined in Winreg.h: HKEY_CLASSES_ROOT (0x80000000) HKEY_CURRENT_USER (0x80000001) HKEY_LOCAL_MACHINE (0x80000002) HKEY_USERS (0x80000003) HKEY_CURRENT_CONFIG (0x80000005) HKEY_DYN_DATA (0x80000006) Note that HKEY_DYN_DATA is a valid tree for Windows 95 and Windows 98 computers only. |
sSubKeyName | String | Specifies the key that contains the named value to be set. |
sValueName | String | Specifies the named value whose data value you are setting. You can specify an existing named value (update) or a new named value (create). Specify an empty string to set the data value for the default named value. |
uValue | UInt8[] | Specifies an array of binary data values. |
Return Value
Returns a value of type UInt32. Typically, a value of 0 indicates success.
Requirements
To use StdRegProv, the following requirements apply:
PowerShell
Get-CimInstance
was introduced with PowerShell Version 3.0, which in turn was introduced on clients with Windows 8 and on servers with Windows Server 2012.
If necessary, update Windows PowerShell to Windows PowerShell 5.1, or install PowerShell 7 side-by-side.
Operating System
StdRegProv was introduced on clients with Windows Vista and on servers with Windows Server 2008.
Namespace
StdRegProv lives in the Namespace Root/default. This is not the default namespace. Use parameter -Namespace root/default with all CIM cmdlets..
Implementation
StdRegProv is implemented in Stdprov.dll and defined in RegEvent.mof. Both files are located in the folder C:\Windows\system32\wbem
:
explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\RegEvent.mof