Sets a value in a registry key.
Set-RegistryKeyValue -Path <String> -Name <String> -String <String> [-Expand] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-RegistryKeyValue -Path <String> -Name <String> -Binary <Byte[]> [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-RegistryKeyValue -Path <String> -Name <String> -DWord <Int32> [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-RegistryKeyValue -Path <String> -Name <String> -QWord <Int64> [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-RegistryKeyValue -Path <String> -Name <String> -Strings <String[]> [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
If the key doesn't exist, it is created. If the value doesn't exist, it is created.
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
Path | String | The path to the registry key where the value should be set. Will be created if it doesn't exist. | true | false | |
Name | String | The name of the value being set. | true | false | |
String | String | The value's data. Creates a value for holding string data (i.e. REG_SZ ).
|
true | false | |
Expand | SwitchParameter | The string should be expanded when retrieved. Creates a value for holding expanded string data (i.e. REG_EXPAND_SZ ).
|
false | false | |
Binary | Byte[] | The value's data. Creates a value for holding binary data (i.e. REG_BINARY ).
|
true | false | |
DWord | Int32 | The value's data. Creates a value for holding a 32-bit integer (i.e. REG_DWORD ).
|
true | false | |
QWord | Int64 | The value's data. Creates a value for holding a 64-bit integer (i.e. REG_QWORD ).
|
true | false | |
Strings | String[] | The value's data. Creates a value for holding an array of strings (i.e. REG_MULTI_SZ ).
|
true | false | |
Force | SwitchParameter | Removes and re-creates the value. Useful for changing a value's type. | false | false | |
WhatIf | SwitchParameter | false | false | ||
Confirm | SwitchParameter | false | false | ||
CommonParameters | This cmdlet supports common parameters. For more information type Get-Help about_CommonParameters . |
Set-RegistryKeyValue -Path 'hklm:\Software\Carbon\Test -Name Status -String foobar
Creates the Status
string value under the hklm:\Software\Carbon\Test
key and sets its value to foobar
.
Set-RegistryKeyValue -Path 'hklm:\Software\Carbon\Test -Name ComputerName -String '%ComputerName%' -Expand
Creates an expandable string. When retrieving this value, environment variables will be expanded.
Set-RegistryKeyValue -Path 'hklm:\Software\Carbon\Test -Name Movies -String ('Signs','Star Wars','Raiders of the Lost Ark')
Sets a multi-string (i.e. array) value.
Set-RegistryKeyValue -Path hklm:\Software\Carbon\Test -Name 'SomeBytes' -Binary ([byte[]]@( 1, 2, 3, 4))
Sets a binary value (i.e. REG_BINARY
).
Set-RegistryKeyValue -Path hklm:\Software\Carbon\Test -Name 'AnInt' -DWord 48043
Sets a binary value (i.e. REG_DWORD
).
Set-RegistryKeyValue -Path hklm:\Software\Carbon\Test -Name 'AnInt64' -QWord 9223372036854775807
Sets a binary value (i.e. REG_QWORD
).
Set-RegistryKeyValue -Path hklm:\Software\Carbon\Test -Name 'UsedToBeAStringNowShouldBeDWord' -DWord 1 -Force
Uses the Force
parameter to delete the existing UsedToBeAStringNowShouldBeDWord
before re-creating it. This flag is useful if you need to change the type of a registry value.