Powershell

How to Use the Remove-ItemProperty Cmdlet in PowerShell?

To delete an item’s property, the “Remove-ItemProperty” cmdlet is used in PowerShell, it removes a property and its value from an item. Moreover, it removes the registry values and the data they store. For instance, if there is an item “Car” and it has a property “Tyre”. So, to delete the “Tyre” which is a property, the user needs to utilize the “Remove-ItemProperty” cmdlet.

This post will provide examples to explain the “Remove-ItemProperty” cmdlet.

How to Use the Remove-ItemProperty Cmdlet in PowerShell?

First, write the “Remove-ItemProperty” cmdlet to delete or remove a property. Then, specify the file or a registry key address to the “-Path” parameter. Next, use the “-Name” parameter to specify the property name that needs to be deleted. Consider the below-provided examples to know more about the “Remove-ItemProperty” cmdlet.

Example 1: Use the “Remove-ItemProperty” Cmdlet to Remove a Property of an Item
Before removing the property, let’s check if the property exists or not by executing the following command:

Get-Item -Path "HKLM:\Software\SampleApp"

First, use the “Get-Item” cmdlet. Then, add the “-Path” parameter and assign it to the registry location where the registry key property is available:

The arrow in the above image is indicating the registry key confirms that the property exists.

Now, run the below-stated command to remove the corresponding property which is a registry key:

Remove-ItemProperty -Path "HKLM:\Software\SampleApp" -Name "AppProperty"

According to the above-stated command:

  • First, use the “Remove-ItemProperty” cmdlet along with the “-Path” parameter having the registry location assigned.
  • Next, utilize the “-Name” parameter and assign it the property to be removed:

After removing the property, let’s check if it was removed or not by utilizing the below command:

Get-Item -Path "HKLM:\Software\SampleApp"

As it can be observed that the property has been removed successfully.

Example 2: Use the “Remove-ItemProperty” Cmdlet to Remove a Registry Value with the Pipe Operator
Execute the provided command to remove an item’s property by utilizing the pipe operator:

Get-Item -Path HKLM:\Software\SampleApp | Remove-ItemProperty -Name NewProperty

Here:

  • First, use the “Get-Item” cmdlet, then add the “-Path” parameter and assign it the corresponding path where the property is residing.
  • Next, pipe the command to the “Remove-ItemProperty” cmdlet, along with the “-Name” parameter having the assigned parameter name that needs to be removed:

That’s all! You have learned about the “Remove-ItemProperty” cmdlet in PowerShell.

Conclusion

To remove a property and its value from an item, the “Remove-ItemProperty” cmdlet can be used in PowerShell. It also removes the registry values and the data they store. This blog described the “Remove-ItemProperty” cmdlet in detail with the help of various examples.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.