所以,我有一个在许多不同的文件夹目录重复一个文件夹,我想避免编写的每一个文件夹的位置。如果可能的话,我只想从1行的所有地方全部删除它们。这是我到目前为止有:删除的文件夹中具有相同名称的目录,但其在目录内不同地方
Remove-Item -Path "C:\Users\dwilson\Desktop\HTFS_v3.9_201511193\Databases" -Filter *onetimescripts* -force -Recurse -ErrorAction SilentlyContinue -Verbose
返回的错误是:
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
我觉得这可能是一个非常简单的修复,但我无法找到它。
尝试做的,而不是一个'删除,Item'一个'GET-ChildItem'和检查结果。如果它找到了你想删除的东西,再次运行该命令并将其传递给'Remove-Item -Force',并让我知道你得到了什么。 – Nate
我也尝试后,我张贴的问题,一开始肯定childitem找到的文件夹,我想删除,但随后告诉我“的路径不存在,”这里是我的说:'GET-ChildItem -Path“C: \用户\ dwilson \桌面\ HTFS_v3.9_201511193 \数据库\”杂牌 “onetimescripts” -Directory -Recurse |删除项目“,他们肯定存在。 – Dpw808
我懂了!我在'remove-item'命令的末尾添加了'force'和'recurse',它工作正常!我以前试过,它没有工作......不知道为什么感谢您的帮助!所以这个问题脱落的列表,请 – Dpw808