Remove ItemProperty - PowerShell
Overview
The Remove-ItemProperty
removes one or more properties from the specified item. It is commonly used to remove metadata, custom properties, or specific attributes from objects such as files, folders, registry keys, and COM objects.
Syntax
Remove-ItemProperty [-Path] <String> -Name <String[]> [-Force] [-Recurse] [-Confirm] [<CommonParameters>]
Options/Flags
- -Path: Specifies the path to the item from which to remove properties. Wildcard characters are supported.
- -Name: The names of the properties to remove. Multiple properties can be specified.
- -Force: Suppresses confirmation prompts when removing items.
- -Recurse: Recursively removes properties from items in subfolders.
- -Confirm: Prompts for confirmation before removing items.
Examples
Simple Example:
Remove-ItemProperty -Path C:\file.txt -Name "Author"
Remove Multiple Properties:
Remove-ItemProperty -Path C:\file.txt -Name "Author", "DateCreated"
Recursively Remove Properties from Subfolders:
Remove-ItemProperty -Path C:\folder\ -Recurse -Name "CustomProperty"
Common Issues
- Non-existent Properties: Attempting to remove a non-existent property will result in an error. Use the
-Confirm
option to review the properties being removed before executing the command. - Permission Denied: The command requires sufficient permissions to modify the items being processed. Ensure that you have the necessary privileges.
Integration
Remove-ItemProperty
can be combined with other PowerShell commands to automate tasks. For example:
Get-Item C:\file.txt | Remove-ItemProperty -Name "Author"
Related Commands
Get-ItemProperty
: Retrieves properties from the specified item.Set-ItemProperty
: Sets properties on the specified item.Clear-ItemProperty
: Clears all properties from the specified item.