This tutorial will elaborate on the usage of PowerShell’s “New-ItemProperty” cmdlet.
How to Use the New-ItemProperty Cmdlet to Create a New Item’s Property in PowerShell?
To create a new item in PowerShell, first, use the “New-ItemProperty” cmdlet. Then specify the property’s path using the “-Path” parameter. After that, use the “-Name” parameter and specify the name for the property. Lastly, mention the value to be assigned to the property by using the “-Value” parameter.
Let’s have an overview of the given examples to understand the usage of the stated cmdlet.
Example 1: Use the “New-ItemProperty” Cmdlet to Add a Registry Entry
Execute the given command to add a new registry entry by utilizing the cmdlet “New-ItemProperty”:
According to the above code:
- First, use the “New-ItemProperty” cmdlet.
- Then, add the “-Path” parameter and specify the stated path.
- After that, use the “-Name” parameter and mention the item name followed by the “-Value” parameter having the stated value assigned to it:
Example 2: Use the “New-ItemProperty” Cmdlet to Add a New Registry Entry to a Key
To add a new registry entry to a key, run the cmdlet “New-ItemProperty”:
Here:
- Initially, use the “Get-Item” cmdlet and assign it the provided path using the “-Path” parameter.
- Then, pipe the provided command to the “New-ItemProperty” cmdlet followed by the “-Name” parameter having the stated value assigned.
- Lastly, add the “-Value” parameter to assign a specified value:
Example 3: Use the “New-ItemProperty” Cmdlet to Create Multi String Values
In order to create multi-string values simply execute the given command:
According to the above command:
- First, initialize a variable “$newVal” and specify the “New-ItemProperty” cmdlet along with the parameter “-Path” the provided path mentioned to it.
- Then, use the parameter “-Name” and specify the name of the property.
- Next, utilize the “-PropertyType” parameter and assign the value “MultiString” to it.
- Lastly, use the “-Value” parameter and provide multiple string values separated by commas enclosed within parentheses:
That’s it! We have illustrated the usage of the “New-ItemProperty” cmdlet in PowerShell.
Conclusion
The “New-ItemProperty” cmdlet is utilized to create a new property for an item in PowerShell. It creates registry values for the registry keys. Moreover, it does not have any aliases in PowerShell. This tutorial elaborated on the usage of PowerShell’s “New-ItemProperty” cmdlet.