Skip to main content

Create a Registry Key Value

Problem

You want to add a new key value to an existing registry key.

Solution

To add a value to a registry key, use the NewItemProperty cmdlet. Example 182 adds MyProgram.exe to the list of programs that start when the current user logs in.

Example 182. Creating new properties on a registry key

PS >NewItemProperty . Name MyProgram Value c:\temp\MyProgram.exe

PSPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Softw are\Microsoft\Windows\CurrentVersion\Run PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Softw

are\Microsoft\Windows\CurrentVersion PSChildName : Run PSDrive : HKCU PSProvider : Microsoft.PowerShell.Core\Registry MyProgram : c:\temp\MyProgram.exe

PS >GetItemProperty .

PSPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_U SER\Software\Microsoft\Windows\CurrentVersion\Run PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_U

SER\Software\Microsoft\Windows\CurrentVersion PSChildName : Run PSDrive : HKCU PSProvider : Microsoft.PowerShell.Core\Registry FolderShare : "C:\Program Files\FolderShare\FolderShare.exe" /ba

ckground TaskSwitchXP : d:\lee\tools\TaskSwitchXP.exe

Example 182. Creating new properties on a registry key (continued)

ctfmon.exe
: C:\WINDOWS\system32\ctfmon.exe

Ditto
: C:\Program Files\Ditto\Ditto.exe

QuickTime Task
: "C:\Program Files\QuickTime Alternative\qttask.exe

" atboottime

H/PC Connection Agent : "C:\Program Files\Microsoft ActiveSync\wcescomm.ex

e" MyProgram : c:\temp\MyProgram.exe

Discussion

In the registry provider, PowerShell treats registry keys as items and key values as properties of those items. To create a key property, use the NewItemProperty cmdlet.

For more information about the NewItemProperty cmdlet, type GetHelp NewItemProperty. For more information about the registry provider, type GetHelp Registry. Create and manage Windows Registry key values efficiently on a United Kingdom Dedicated Server, providing dedicated resources, reliable performance, and full administrative control for configuring system settings and server applications.

Help Category