Delete the specified items.

      Remove-Item { [-path] string[] | [-literalPath] string[] }
         [-include string[]] [-exclude string[]] [-filter string]
            [-recurse] [-force] [-whatIf] [-confirm]
               [-credential PSCredential] [-UseTransaction] [CommonParameters]

   -Path string
       The path(s) to the items. Wildcards are permitted.
       Use the wildcard (*) to specify all items in the current location.

   -LiteralPath string
       Like Path above, only the value is used exactly as typed.
       No characters are interpreted as wildcards. If the path includes any
       escape characters then enclose the path in single quotation marks.
   -Include string
       Include only the specified items from the Path. e.g. "May*"
       this only works when the path includes a wildcard character.
   -Exclude string
       Omit the specified items from the Path e.g. "*SS64*"
       this only works when the path includes a wildcard character.
   -Filter string
       A filter in the provider's format or language. 
       The exact syntax of the filter (wildcard support etc) depends on the provider.
       Filters are more efficient than -include/-exclude, because the provider
       applies the filter when retrieving the objects, rather than having 
       PowerShell filter the objects after they are retrieved.

       Also delete child items from the specified location.
       [Does NOT Work properly yet - see example below]

       Override restrictions that prevent the command from succeeding, apart
       from security settings. e.g. -force will override a files read-only
       attribute, but will not change file permissions.

   -Credential PSCredential
       Use a credential to validate access to the file. Credential represents
       a user-name, such as "User01" or "Domain01\User01", or a PSCredential
       object, such as the one retrieved by using the Get-Credential cmdlet.
       If you type a user name, you will be prompted for a password.
       This parameter is not supported by any PowerShell core cmdlets or providers.

       Describe what would happen if you executed the command without
       actually executing the command.

       Prompt for confirmation before executing the command.

       Include the command in the active transaction.

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Standard Aliases for Remove-Item: del, erase, rd, rm, rmdir, ri

Remove-Item deletes one or more items. It can be used to delete many different types of items, including files, directories, registry keys, variables, aliases, and functions.


Delete filenames that include a dot (.)

PS C:\> remove-item C:\Docs\*.*

Delete from the current directory (*) all files with a .doc file name extension and a name that does not include "1".

PS C:\> remove-item * -include *.doc -exclude *1*

Delete a file that is both hidden and read-only.:

PS C:\> remove-item -path C:\Docs\hidden-RO-file.txt -force

Delete only a folder called ss64:

PS C:\> remove-item ss64 | Where { $_.PSIsContainer }

Delete only a file called ss64:

PS C:\> remove-item ss64 | Where { ! $_.PSIsContainer }

Delete all of the CSV files in the current directory and all subdirectories recursively - because remove-item -recurse is faulty this uses get-childitem -recurse instead:

PS C:\> get-childitem * -include *.csv -recurse | remove-item

Remove a variable called $myVar:

PS C:\> remove-item variable:myVar

Delete an alias named 'list'

PS C:\> Remove-item alias:list

Delete the 'demo' registry key and all of its subkeys and values:

PS C:\> remove-item hklm:\software\SS64\demo -recurse

“It devoured my paper, it was a really good paper” ~ Ellen Feiss


Clear-item - Remove content from a variable or an alias
Get-item - Return an object that represents an item in a namespace
invoke-item - Invoke an executable or open a file (START)
Move-item - Move an item from one location to another
New-item ni Create a new item in a namespace
Set-item - Set the value of a provider pathname
Rename-item - Change the name of an existing item
Equivalent bash command: rm - Remove files

Copyright © 1999-2017
Some rights reserved