Categories

Registry 3

Lets look at changing registry values. In http://msmvps.com/blogs/richardsiddaway/archive/2010/07/16/registry-1.aspx  I showed how to read the registry. We’ll change the 4 values we found in that post

001
002
003
004
005
006
007
008
$reg = [Microsoft.Win32.Registry]::LocalMachine
$key = $reg.OpenSubKey("Software\ITKE PSAdmins", $true)
$key.SetValue("Dword Entry", 567 ,"Dword") 
$key.SetValue("String Entry", "My new string" ,"String") 
$key.SetValue("Expanded String Entry", "%COMPUTERNAME%" ,"ExpandString")

[string[]]$multi = "Z","Y","X"
$key.SetValue("Multi-string Entry", $multi ,"MultiString")

 

Open the key as we did before except this time add a second parameter. $true indicates that the key is opened in a readable state. The SetValue method can be used to set the appropriate values. The parameters are the name of the value, the new value and the data type. Notice that for the multi-string value we supply and array of strings.

The acceptable data types are:

PS> Get-Enum Microsoft.Win32.RegistryValueKind
Unknown
String
ExpandString
Binary
DWord
MultiString
QWord

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>