删除同名目录中的文件夹,但它在目录中的不同位置

Deleting a folder in a directory with the same name, but its in different places inside the directory

所以,我有一个文件夹在许多不同文件夹的目录中重复出现,我想避免对每个文件夹位置进行编码。如果可能的话,我只想从 1 行的所有位置删除所有这些。这是我目前所拥有的:

Remove-Item -Path "C:\Users\dwilson\Desktop\HTFS_v3.9_201511193\Databases" -Filter *onetimescripts* -force -Recurse -ErrorAction SilentlyContinue -Verbose

它 returns 的错误是:

 Remove-Item : Cannot remove item 
    C:\Users\dwilson\Desktop\HTFS_v3.9_201511193\Databases\HTFSJob\BAM\onetimescripts: 
     The directory is not empty.
At line:1 char:1
+ Remove-Item -Path "C:\Users\dwilson\Desktop\HTFS_v3.9_201511193\Databases" -Filt 
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (onetimescripts:DirectoryInfo) [Remove-It 
   em], IOException
    + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Comm 
   ands.RemoveItemCommand

我觉得这可能是一个非常简单的修复,但我找不到它。

这个问题的答案是:

Get-ChildItem -Path "C:\path" -Name "foldername" -Directory -Recurse | Remove-Item -Force -Recurse