remove more than one folder

hi, I am having trouble in removing more than a folder, I tried:

Remove-Item C:\Users\vitor\Desktop\tempS9\#paraDistribuir, C:\Users\vitor\Desktop\tempS9\Chinese,

but I got the error:

+ CategoryInfo : InvalidArgument: (:) [Remove-Item], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

Remove-Item only accepts one path at a time.

If you want to remove everything stored in tempS9 you can use a wildcard like this:

Remove-Item C:\Users\vitor\Desktop\tempS9\*

but be careful because this will remove everything in that directory.

If you need to remove specific items in that directory then the easiest thing to do is store the names of the things you want to remove in an array and then use a foreach loop to apply Remove-Item to each one.

Also, if your file path actually has a # symbol in it as shown in your command then you will need to wrap the path in quotes like this:


It’s generally safer to wrap paths in quotes to ensure that they are interpreted correctly.

# Remove folders and all contents
$array = @(
Get-Item -Path $array | Remove-Item -Recurse -Verbose -WhatIf