Cannot remove item. The directory is not empty

后端 未结 3 941
心在旅途
心在旅途 2021-02-01 13:13

I am trying to delete a folder with subfolders/files.

Remove-Item -Force -Recurse -Path $directoryPath

I am getting the error Cannot remo

3条回答
  •  后悔当初
    2021-02-01 14:10

    this worked for me where i deleted files and folders older then i year recursively including folders.

    Get-ChildItem -Directory -Path X:\AutomateCache | where-Object {$_.Lastwritetime -ile (get-date).AddMonths(-12) } | Remove-Item -Force -Recurse -Verbose

提交回复
热议问题