PowerShell Logo Small

New-ItemProperty



This is the built-in help made by Microsoft for the command 'New-ItemProperty', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Creates a new property for an item and sets its value. For example, you can use New-ItemProperty to create and change registry values and data, which are properties of a registry key.

SYNTAX


New-ItemProperty [-Path] <String[]> [-Name] <String> [-Credential [<PSCredential>]] [-Exclude [<String[]>]] [-Filter [<String>]] [-Force] [-Include [<String[]>]]
[-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-PropertyType [<String>]] [-Value
[<Object>]] [-Confirm] [-WhatIf] [-UseTransaction [<SwitchParameter>]] [<CommonParameters>]
New-ItemProperty [-Name] <String> [-Credential [<PSCredential>]] [-Exclude [<String[]>]] [-Filter [<String>]] [-Force] [-Include [<String[]>]] [-InformationAction
{SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-PropertyType [<String>]] [-Value [<Object>]] -LiteralPath
<String[]> [-Confirm] [-WhatIf] [-UseTransaction [<SwitchParameter>]] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The New-ItemProperty cmdlet creates a new property for a specified item and sets its value. Typically, this cmdlet is used to create new registry values, because registry
values are properties of a registry key item.


This cmdlet does not add properties to an object. To add a property to an instance of an object, use the Add-Member cmdlet. To add a property to all objects of a particular
type, edit the Types.ps1xml file.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=293887
Clear-ItemProperty
Copy-ItemProperty
Get-ItemProperty
Move-ItemProperty
Remove-ItemProperty
Rename-ItemProperty
Set-ItemProperty
about_Providers

REMARKS

<

Examples


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

PS C:\>new-itemproperty -path HKLM:\Software\MyCompany -name NoOfEmployees -value 822
PS C:\>get-itemproperty hklm:\software\mycompany

PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\mycompany
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software
PSChildName : mycompany
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
NoOfLocations : 2
NoOfEmployees : 822



This command adds a new registry entry, NoOfEmployees, to the MyCompany key of the HKLM:\Software hive.

The first command uses the Path parameter to specify the path to the MyCompany registry key. It uses the Name parameter to specify a name for the entry and the Value
parameter to specify its value.

The second command uses the Get-ItemProperty cmdlet to see the new registry entry.










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

PS C:\>get-item -path HKLM:\Software\MyCompany | new-Itemproperty -name NoOfLocations -value 3



This command adds a new registry entry to a registry key. To specify the key, it uses a pipeline operator (|) to send an object representing the key to the New-ItemProperty
cmdlet.

The first part of the command uses the Get-Item cmdlet to get the MyCompany registry key. The pipeline operator (|) sends the results of the command to the New-ItemProperty
cmdlet, which adds the new registry entry, NoOfLocations, and its value, 3, to the MyCompany key.

This command works because the parameter-binding feature of Windows PowerShell associates the path of the RegistryKey object that Get-Item returns with the LiteralPath
parameter of New-ItemProperty. For more information, see about_Pipelines.