I want to use powershell to remove all files with size smaller than 100gb and used
ls | where {$_.Length -lt 100gb} | Remove-Item -Force-Recurse
But got this error
Remove-Item : A parameter cannot be found that matches parameter name 'Force-Recurse'.
At line:1 char:48
+ ls | where {$_.Length -lt 100gb} | Remove-Item -Force-Recurse
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Remove-Item], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
What has gone wrong here?
It is just a matter of adding an extra space between parameters. Also make sure you really want to recursively delete the files from all subfolders:
ls | where {$_.Length -lt 100gb} | Remove-Item -Force -Recurse