Deleting files, folders, registry keys, and named values
When you are creating scripts, there are instances when you need to delete items from a computer. PowerShell has the remove-item
cmdlet that enables the removal of objects from a computer. The syntax of this cmdlet starts by calling the remove-item
cmdlet and proceeds with specifying the –path
argument with a file, folder, or registry key to delete.
The remove-item
cmdlet has several useful arguments that can be leveraged. The –force
argument is available to delete files, folders, and registry keys that are read-only, hidden, or restricted by UAC. The –recurse
argument is available to enable recursive deletion of files, folders, and registry keys on a system. The –include
argument enables you to delete specific files, folders, and registry keys. The –include
argument allows you to use the wildcard character of an asterisk (*
) to search for specific values in an object name or a specific object type. The –exclude
argument will exclude...