windows - 删除 powershell 中的子目录,包括符号链接(symbolic link)

标签 windows powershell scripting

目前遇到问题,我目前正在这样做:

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/

相关文章:

c++ - 在 C++ 中从另一个线程终止一个线程

windows - 将客户端打印机映射到 Windows 终端服务器的 API

java - 程序暂停,直到用户按下 Control+C

windows - 无法通过 runas 命令捕获输出

powershell - 是否可以自动制作天蓝色弹性泳池秤?

powershell - "Cannot bind parameter because Param2 is specified more than once"

shell - 最优雅的 unix shell 单行来求和任意精度的数字列表?

linux - 使用 grep 选择与列表中的任何单词匹配的行

Azure Powershell 诊断设置

无法访问 'unsafe' java 方法的 java 表达式语言