目前遇到问题,我目前正在这样做:
Get-ChildItem $PATH -Recurse -ErrorAction SilentlyContinue |
Where-Object {($_.Attributes -notmatch '\"Directory\"') -and
($_.LastWriteTime -lt (Get-Date).AddHours(-12))}|
Remove-Item -Force -Recurse
现在,如果我没有符号链接(symbolic link),它会很好地删除,但我有。我收到此错误:
Remove-Item : There is a mismatch between the tag specified in the request and the tag present in the reparse point At line:1 char:184 + ... ($_.LastWriteTime -lt (Get-Date).AddHours(-12))}| Remove-Item -Force + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Remove-Item], Win32Exception + FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.RemoveItemCommand
我无法将 powershell 升级到 v6。似乎与:https://github.com/powershell/powershell/issues/621#issuecomment-289230180
有人有解决方法吗?
最佳答案
今天在 PowerShell 7
上测试不幸的是,问题仍然存在:PowerShell 无法删除符号链接(symbolic link)。
我必须通过提升提示符键入 cmd /c rmdir /s /q C:\Users\Your_User_Name\Your_Folder_Name
来删除目录
关于windows - 删除 powershell 中的子目录,包括符号链接(symbolic link),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51160864/